feat: add feature-flag admin API with audit logging - #798
Merged
thlpkee20-wq merged 4 commits intoAug 29, 2026
Conversation
|
@bubah911 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Overview
This PR adds a feature-flag admin API that lets authorized operators inspect and toggle runtime flags without redeploys. It exposes
GET /api/admin/feature-flagsto return the current flag map andPATCH /api/admin/feature-flagsto flip a flag’sEnabledstate through the existingfeatureflags.Manager. Every mutation is written to the audit sink with actor and before/after state.Related Issue
Closes #
Changes
🚩 Feature Flag Admin API
[ADD]
internal/handlers/feature_flags.goListhandler returns the current feature-flag map from the manager.Patchhandler accepts the target flag name and desiredEnabledstate, validates the input, and toggles the flag via the manager.404; malformed bodies, missing fields, and invalid flag names return400.manage:subscriptionspermission and anIdempotency-Keyheader onPATCH.[MODIFY]
internal/featureflags/featureflags.goSetEnabledmethod toManagerfor safe runtime updates.LoadDefaultFlagsandLoadFromEnvironmentbehavior.PATCHrequests are serialized by the manager mutex; no partial or interleaved updates occur.[MODIFY]
internal/audit/middleware.goaudit.LogAction.[MODIFY]
internal/middleware/featureflags.go[MODIFY]
internal/handlers/routes.goGET /api/admin/feature-flagsandPATCH /api/admin/feature-flagsunder the admin group.[ADD] Test coverage for handler happy paths, invalid/unknown inputs, authorization boundaries, concurrent PATCH serialization, duplicate idempotency keys, audit failure behavior, and backward compatibility.
Verification Results
go test ./...with a clear reviewable contractGET/PATCH /api/admin/feature-flagsadded with handler, manager, middleware, route, and audit wiringmanage:subscriptionsenforced,Idempotency-Keyrequired, input validation and 400/404 boundaries coveredCloses #787