feat: [FME-19299]: FME CLI — segment_definition membership keys - #246
Open
apetruccelli wants to merge 8 commits into
Open
apetruccelli wants to merge 8 commits into
apetruccelli wants to merge 8 commits into
Conversation
apetruccelli
force-pushed
the
FME-19299-segment-keys
branch
from
September 28, 2026 13:49
868ed9b to
b76e074
Compare
Adds list/add/remove commands for segment_definition membership keys, scoped to the base FME-17257/FME-17260 segment CRUD (no object_set or tags/owners dependency).
apetruccelli
force-pushed
the
FME-19299-segment-keys
branch
from
September 28, 2026 13:52
b76e074 to
cf2ccb9
Compare
puthrayaharness
approved these changes
Sep 30, 2026
Main PR #12932 added optional comment/title query params to
DELETE /v4/segment-definitions/{name} for the archive audit trail,
but the CLI had no --comment/--title flags to reach them, so a
workspace requiring a title (e.g. qa0) always 400s on this command.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…Create/Update List and Delete were already covered; this fills in the remaining CRUD operations on segment_definition to close the gap identified while reviewing FME-17260. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolve spec/test conflicts: keep main's body-based segment:definition delete (comment/title, harness#265) and drop the superseded query-param tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ove-keys Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds membership-key management for
segment:definition, against the v4/fme/api/v4/segment-definitions/{name}/keysAPI.list segment:definition:keys <segment-name> --env <env-id>— paginated (offset/limit, max 100), wraps the endpoint's bare string array into{key: ...}for field rendering. The ticket names thisexecute segment:definition:list-keys, butexecutein this CLI never wires up--offset/--limit/--all(only thelistverb handler does), and the establishedfeature_flag:definitionconvention already keeps sub-resource reads on their natural CRUD verb rather than wrapping them inexecute. Keptlisthere to preserve pagination and match that precedent.execute segment:definition:add-keys <segment-name> --env <env-id> [--key ...] [--keys-file <path>] [--replace] [--comment] [--title]— POST with repeatable--key,--keys-file, or both, sent as a single request (up to 10000 keys). An optional--replaceswaps the whole membership instead of appending (only sent when set, since the endpoint already defaultsreplace=false), and optional audit--comment/--titleare sent only when passed (absent, not null, when omitted).execute segment:definition:remove-keys <segment-name> --env <env-id> [--key ...] [--keys-file <path>]— POST to.../keys/remove(not DELETE: the keys travel in a body, and DELETE with a body is unreliable across HTTP clients). Accepts the same--keyand--keys-fileinputs.--keys-file <path>— loads keys from a file, or from stdin with-. Every cell is a key, so one key per line, a single comma-separated row, and multi-column CSVs all work; quoted cells may contain commas. Whitespace is trimmed, blank cells are skipped, and duplicates are dropped (first-seen order kept). A UTF-8 BOM and CRLF line endings are handled. The file must contain only keys (no header row). An empty file is an error, and so is a request with neither--keynor--keys-file(unless--replaceis set); more than 10000 keys is rejected before the request is sent.add-keysandremove-keyscarry along:description of the--keys-fileformat, soharness execute segment:definition:add-keys --helpdocuments it for users and agents.no_fields: true— the response is the submitted keys plus a governance result, not a segment, so rendering the segment noun's fields against it previously printed a block of blank labels. The success line reports the number of keys sent.Covered by unit tests in
pkg/specloader/fme_spec_test.go(TestFMESpec_ListSegmentKeys,TestFMESpec_AddSegmentKeys,TestFMESpec_SegmentKeysMutation_NoFields,TestFMESpec_RemoveSegmentKeys,TestFMESpec_AddKeys_MergesKeyAndKeysFile,TestFMESpec_RemoveKeys_KeysFileOnly,TestFMESpec_AddKeys_NoKeysRejected,TestFMESpec_AddKeys_HeaderCountsAllKeys) and inmodules/fme/segment_keys_test.gofor file parsing, resolution and validation.Commands
harness list segment:definition:keys <segment-name> --env <env-id>harness execute segment:definition:add-keys <segment-name> --env <env-id> --key <key> [--key <key> ...] [--replace] [--comment <text>] [--title <text>]harness execute segment:definition:add-keys <segment-name> --env <env-id> --keys-file keys.csv [--replace] [--comment <text>] [--title <text>]harness execute segment:definition:remove-keys <segment-name> --env <env-id> --key <key> [--key <key> ...] [--comment <text>] [--title <text>]harness execute segment:definition:remove-keys <segment-name> --env <env-id> --keys-file keys.csv [--comment <text>] [--title <text>]Testing
Verified live end-to-end against a real qa0 project:
--key, list reflects them, remove one key, list reflects the removal, and a--replacepass swaps the whole membership.--keys-filewith a 100-key one-per-line CSV, the same keys as a single comma-separated row, and a file with blank cells, duplicates and a quoted comma: the segment holds each key once anduser,with,commasis stored as one key.--keys-file -from stdin,--keycombined with--keys-file,remove-keys --keys-file, and--replacewith a file.comment+titlerequirement is workspace-specific policy (not a general contract): qa0 requires both, while a prod profile accepts the calls with no audit fields.Acceptance Criteria
--comment/--titlesupported and omitted (not null) when not passedExtra test coverage
segment:definitionhad unit tests for List and Delete but not Get/Create/Update. AddedTestFMESpec_GetSegmentDefinition,TestFMESpec_CreateSegmentDefinition, andTestFMESpec_UpdateSegmentDefinition, following the same patterns already used for thesegmentnoun's CRUD tests. No spec changes — test-only addition.