Skip to content

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
harness:mainfrom
apetruccelli:FME-17257-fieldtype-owners-tags
Open

apetruccelli wants to merge 4 commits into
harness:mainfrom
apetruccelli:FME-17257-fieldtype-owners-tags

Conversation

@apetruccelli

@apetruccelli apetruccelli commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Context

feature_flag and segment needed three things metric already has: mutable owners/tags, a way to build a request body from a file (-f) instead of flags, and (for feature_flag:definition) mutable flag_sets. This PR adds all three, reusing the same field-type/file_body machinery already proven on metric.

Changes

  • fme:owners / fme:tags field types (modules/fme/owners.go, modules/fme/tags.go): generic Normalize/Mutate/Encode handlers per docs/mutation.md, wired onto owners/tags on both feature_flag and segment.
    • Owners: --add/--del owners.user:<email>, owners.user:<id>, or owners.group:<identifier>, matching v4's OwnerReferenceInput write shape.
    • Tags: --add/--del tags.<name>; Encode strips the read-only id before writing.
    • A GROUP owner's identifier is read back from the id key on GET (Harness user groups have no separate UUID), so it round-trips through a --set/--add/--del on the same field without being dropped.
    • update_body_pick for both nouns carries both collections so mutating one preserves the other in the merge-PATCH.
  • fme:flag_sets field type (modules/fme/flagsets.go): --add/--del flag_sets.<id> on feature_flag:definition, keyed by id per v4's FlagSetReference (name/type are neither accepted nor returned). update_body_pick now also carries flagSets alongside the existing scalars.
  • File-body (-f) support: create/update feature_flag and create/update segment now accept file_body: optional, letting a JSON file stand in for (or alongside) flag-built request bodies.
    • Dropped required: true from --traffic-type (feature_flag, segment create) and --segment-type (segment create) — same required-flag fix already shipped for metric — since a required flag would otherwise block a -f-only invocation with a 400 before the request goes out. update segment keeps --segment-type required, 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 ./... and go test ./... pass.
  • Tests in pkg/specloader/fme_spec_test.go:
    • TestFMESpec_UpdateFeatureFlag_AddDelTags / TestFMESpec_UpdateFeatureFlag_AddDelOwners / TestFMESpec_CreateFeatureFlag_TagsOwners
    • TestFMESpec_UpdateFeatureFlag_Owners_PreservedGroupRoundTrips
    • TestFMESpec_UpdateSegment_AddDelTags / TestFMESpec_UpdateSegment_AddDelOwners / TestFMESpec_CreateSegment_TagsOwners
    • TestFMESpec_CreateFeatureFlag_FileBody / TestFMESpec_UpdateFeatureFlag_FileBody
    • TestFMESpec_CreateSegment_FileBody / TestFMESpec_UpdateSegment_FileBody
    • TestFMESpec_UpdateFeatureFlagDefinition_AddDelFlagSets
  • Live-verified end-to-end against qa0: add/del tags, add-by-email/del-by-id/del-by-group owners, a GROUP owner surviving a USER owner delete on the same field, -f create/update for both feature_flag and segment, and an add/del round trip on flag_sets for feature_flag:definition.

Acceptance Criteria

  • fme:owners/fme:tags field types implemented per docs/mutation.md
  • Wired onto feature_flag and segment
  • GROUP owners round-trip correctly (identifier read back from id)
  • Owners addressable by user email, user id, or group identifier
  • fme:flag_sets field type wired onto feature_flag:definition
  • File-body (-f) support on feature_flag and segment create/update
  • Unit tests for all of the above, live-verified against qa0

🤖 Generated with Claude Code

apetruccelli and others added 3 commits September 29, 2026 10:35
…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>
@apetruccelli apetruccelli changed the title feat: [FME-17257]: add fme:owners and fme:tags field types for feature_flag feat: [FME-17257]: add fme:owners and fme:tags field types for feature_flag and segment Sep 29, 2026
…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>
@apetruccelli apetruccelli changed the title feat: [FME-17257]: add fme:owners and fme:tags field types for feature_flag and segment feat: [FME-17257]: add owners/tags field types, flag_sets, and file (-f) support for feature_flag and segment Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant