feat: [FME-17257]: add owners/tags field types, flag_sets, and file (-f) support for feature_flag and segment - #257
Open
apetruccelli wants to merge 4 commits into
Conversation
…e_flag Supersedes the object_set-based approach from cli#244/harness#245, which the team decided against (see docs/mutation.md, merged via harness#247-harness#256). This wires feature_flag's owners/tags collections into the new per-module field_type handler framework instead. - New modules/fme package, registered in main-harness.go: fme:owners and fme:tags handlers (Normalize/Mutate/Encode), following the Normalize -> Mutate (per --add/--del op, in CLI order) -> Encode lifecycle. - feature_flag's owners/tags fields get mutable_path + field_type; the update command's update_body_pick now carries both collections so a mutation can preserve the other members (merge-PATCH replaces the whole array). - Owners support add/del by "user:<email>", "user:<id>", or "group:<identifier>", matching v4's OwnerReferenceInput write shape and the email support added in Main #12882. Existing GROUP owners picked up from a GET cannot be re-encoded (v4's read side returns a group's name, never its identifier), so encodeOwners errors clearly instead of dropping the group or sending a broken request -- a known limitation until the server returns it (documented in docs/mutation.md). - Tags support add/del by name; Encode strips the read-only id before writing, since v4's TagReferenceInput only accepts {name}. - segment is intentionally untouched in this change; same treatment follows in a separate pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
v4's read shape carries a GROUP owner's identifier under "id" (the same key USER owners use), not a separate "identifier" field — confirmed live against qa0. encodeOwners required "identifier" and had no fallback, so any flag with a GROUP owner became permanently stuck on the next owners edit. Fall back to "id" when "identifier" is absent, and match on it too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Follow-up to harness#257 — wires the same fme:owners/fme:tags field types (no new Go code needed, they're already generic) into the segment noun: mutable_path + field_type on tags/owners, and update_body_pick widened to carry both collections so add/del preserves the other's members under merge-PATCH. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…y for feature_flag and segment - create/update feature_flag and create/update segment now accept file_body (-f) as an alternative to building the request from flags - dropped required: true from --traffic-type (feature_flag, segment create) and --segment-type (segment create), matching metric's existing required-flag fix, so a file body alone can satisfy them; update segment keeps --segment-type required since it is a query-param used for routing, not a body field a file could supply - added fme:flag_sets field type (modules/fme/flagsets.go) so --add/--del flag_sets.<id> can manage a feature flag definition's flag set associations, keyed by id per FlagSetReference Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Sep 29, 2026
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.
Context
feature_flagandsegmentneeded three thingsmetricalready has: mutableowners/tags, a way to build a request body from a file (-f) instead of flags, and (forfeature_flag:definition) mutableflag_sets. This PR adds all three, reusing the same field-type/file_bodymachinery already proven onmetric.Changes
fme:owners/fme:tagsfield types (modules/fme/owners.go,modules/fme/tags.go): genericNormalize/Mutate/Encodehandlers perdocs/mutation.md, wired ontoowners/tagson bothfeature_flagandsegment.--add/--del owners.user:<email>,owners.user:<id>, orowners.group:<identifier>, matching v4'sOwnerReferenceInputwrite shape.--add/--del tags.<name>;Encodestrips the read-onlyidbefore writing.idkey on GET (Harness user groups have no separate UUID), so it round-trips through a--set/--add/--delon the same field without being dropped.update_body_pickfor both nouns carries both collections so mutating one preserves the other in the merge-PATCH.fme:flag_setsfield type (modules/fme/flagsets.go):--add/--del flag_sets.<id>onfeature_flag:definition, keyed byidper v4'sFlagSetReference(name/type are neither accepted nor returned).update_body_picknow also carriesflagSetsalongside the existing scalars.-f) support:create/update feature_flagandcreate/update segmentnow acceptfile_body: optional, letting a JSON file stand in for (or alongside) flag-built request bodies.required: truefrom--traffic-type(feature_flag,segmentcreate) and--segment-type(segmentcreate) — same required-flag fix already shipped formetric— since a required flag would otherwise block a-f-only invocation with a 400 before the request goes out.update segmentkeeps--segment-typerequired, since there it's a query-param used for routing, not a body field a file could supply instead.Commands
harness update feature_flag <name> --add owners.user:<email> --org <org> --project <project>harness update feature_flag <name> --del owners.group:<identifier> --org <org> --project <project>harness update feature_flag <name> --add tags.<name> --del tags.<name> --org <org> --project <project>harness create segment <name> --traffic-type <type> --segment-type STANDARD --add tags.<name> --add owners.user:<email> --org <org> --project <project>harness update segment <name> --segment-type STANDARD --add owners.group:<identifier> --del owners.user:<id> --org <org> --project <project>harness create feature_flag <name> -f ff.json --org <org> --project <project>harness update feature_flag <name> -f patch.json --org <org> --project <project>harness create segment <name> -f segment.json --org <org> --project <project>harness update segment <name> --segment-type STANDARD -f patch.json --org <org> --project <project>harness update feature_flag:definition <name> --env <env-id> --add flag_sets.<flag-set-id> --del flag_sets.<flag-set-id> --org <org> --project <project>Testing
go build ./...andgo test ./...pass.pkg/specloader/fme_spec_test.go:TestFMESpec_UpdateFeatureFlag_AddDelTags/TestFMESpec_UpdateFeatureFlag_AddDelOwners/TestFMESpec_CreateFeatureFlag_TagsOwnersTestFMESpec_UpdateFeatureFlag_Owners_PreservedGroupRoundTripsTestFMESpec_UpdateSegment_AddDelTags/TestFMESpec_UpdateSegment_AddDelOwners/TestFMESpec_CreateSegment_TagsOwnersTestFMESpec_CreateFeatureFlag_FileBody/TestFMESpec_UpdateFeatureFlag_FileBodyTestFMESpec_CreateSegment_FileBody/TestFMESpec_UpdateSegment_FileBodyTestFMESpec_UpdateFeatureFlagDefinition_AddDelFlagSets-fcreate/update for bothfeature_flagandsegment, and an add/del round trip onflag_setsforfeature_flag:definition.Acceptance Criteria
fme:owners/fme:tagsfield types implemented perdocs/mutation.mdfeature_flagandsegmentid)fme:flag_setsfield type wired ontofeature_flag:definition-f) support onfeature_flagandsegmentcreate/update🤖 Generated with Claude Code