Introducing a new way to review your PRs.

Read the announcement

thomaspoignant / go-feature-flag

GO Feature Flag is a simple, complete and lightweight self-hosted cloud native feature flag solution 100% Open Source — built on OpenFeature 🎛️

View on GitHub

18 documents · Updated Nov 23, 2026

docs / change-notifications

Flag change notifications

Flag change notifications tell operators when the loaded feature-flag configuration changes. The system compares the previous and current flag sets after a retriever refresh, builds one shared change record, and sends that record to each configured delivery channel without changing flag evaluation itself. See SDK configuration and flag retrieval for the refresh lifecycle that supplies the two configurations.

Notification purpose

Notifications report configuration changes rather than flag evaluation results. They help a team see when a flag is created, removed, or changed, and they can also let another system react through a webhook.

Change boundaries

The notification service runs after a new configuration is loaded into the in-memory cache. It compares the complete old and new flag sets, so a refresh with no effective change produces no notification. A change is reported only when at least one flag is added, deleted, or updated.

The initial load is also a configuration change by default. DisableNotifierOnInit can suppress that first notification when startup should not look like a mass flag creation event. Later polling refreshes and explicit refreshes still use the normal change path. Offline operation sends no notifications.

References: internal/…/cache_manager.go• L74-101 retriever/manager.go• L189-213 config.go• L31-37 config.go• L92-95

Configuration diff

The configuration diff is the common contract between cache refreshes and delivery channels. It keeps the change type at the flag-key level while retaining the full flag value for additions and deletions and both values for updates.

Diff categories

Each changed flag belongs to one of three categories:

CategoryMeaningData carried
AddedA key exists only in the new configuration.The new flag value
DeletedA key exists only in the old configuration.The old flag value
UpdatedA key exists in both configurations but its flag value differs.The old and new flag values

An update includes any meaningful difference in the flag value. Delivery channels may turn that pair into a human summary, but the shared diff does not limit the change to one field.

References: notifier/diff_cache.go• L7-23 internal/…/notification_service.go• L57-87

Field-level changes

Field-level changes provide a structured view of the old and new values for an updated flag. The system reports dot-separated paths, uses null when a field is added or removed, and sorts paths for stable output. JSON is used for readable values when possible, with a Go-form fallback for values that JSON cannot encode.

Chat notifications use a separate change description that explains the flag behavior in plain language. It follows the order of fields in the flag file and covers flag state, event tracking, variations, targeting rules, default rules, rollouts, experimentation windows, metadata, and scheduled steps. It pairs targeting rules by name when possible, uses position for unnamed or duplicate names, and detects simple renames without treating the rule as removed and added. Scheduled steps pair by date when possible and then by position. Their contents are described as partial updates because they change only the fields they set.

The description keeps values readable for people. Slack and Discord can use Markdown inline code, while Microsoft Teams uses plain text. The reserved updatedBy metadata identifies the person in a flag title but is not listed as a metadata field change. If the flag type cannot be described, chat output shows Changes could not be computed with the error instead of hiding the update. A change list shows at most 50 entries and adds a count for entries it omits.

References: notifier/describe.go• L15-92 notifier/describe.go• L137-159 notifier/describe.go• L221-272 notifier/describe.go• L400-476 notifier/describe_test.go• L678-715 notifier/describe_test.go• L719-786

Notification flow

The refresh path updates the active cache first and then evaluates whether notifications are enabled for that refresh. The service sends the same diff to all notifiers in parallel, so one slow destination does not define the work of the other destinations.

This diagram shows how a retrieved configuration becomes a set of independent notifications.

flowchart LR
    A[Retriever refresh] --> B[Build new flag cache]
    B --> C[Compare old and new flag sets]
    C --> D{Any added, deleted, or updated flags?}
    D -- No --> E[No notification]
    D -- Yes --> F[Shared DiffCache]
    F --> G[Logs]
    F --> H[Chat webhook]
    F --> I[Generic webhook]
    F --> J[Other configured notifiers]

The cache manager owns the point at which the old and new snapshots are available. The notification service owns diff creation and fan-out. Each notifier owns the final message format or request sent to its destination.

References: retriever/manager.go• L56-94 internal/…/cache_manager.go• L74-101 internal/…/notification_service.go• L32-55

Notifier contract

notifier.Notifier is the extension contract for a delivery channel. A notifier receives one notifier.DiffCache and returns an error when it cannot deliver or format the notification.

Delivery behavior

The notification service applies the same rules to every notifier:

  • It does not call any notifier when the diff is empty.
  • It calls every configured notifier when the diff has at least one change.
  • It runs notifier calls independently and concurrently.
  • It logs a notifier error without stopping the other notifier calls.
  • It waits for active notifier calls during shutdown.

This contract keeps change detection separate from destination behavior. A new channel needs to understand the shared diff and report its own delivery errors; it does not need to compare flag sets.

References: notifier/notifier.go• L3-7 internal/…/notification_service.go• L15-55

Delivery channels

The built-in channels consume the same diff but present it for different operating needs. Logs give a local event trail, chat channels give a human-readable alert, and the generic webhook exposes structured data for another service.

Log delivery

The log notifier writes one event for each added or deleted flag. For an updated flag it distinguishes a change to the disabled state from another update, so operators can see when a flag turns on or off.

References: notifier/…/notifier.go• L10-41

Chat delivery

Slack, Discord, and Microsoft Teams send a human-readable message to their webhook endpoints. Each message identifies the running host and lists added, deleted, and updated flags. Added and updated flag titles include the updatedBy name when the flag metadata provides one. Updated flags use the shared semantic change description rather than a raw field diff. Slack uses Markdown code spans and escapes characters that could create a mention or link. Microsoft Teams uses plain text because its card format has no inline-code support.

The channels use destination-specific message shapes and ordering. Slack and Microsoft Teams list deleted, added, and updated flags. Discord sends one embed per flag when possible and sorts the embeds by title. Discord keeps the full message within its embed count, title, description, and total-size limits. When the change set is too large, it shortens change lists and tells operators to check the logs. Slack and Teams include the available change details and still cap each change list at 50 entries. When a comparison fails, each chat message includes the shared failure label and error.

References: notifier/describe.go• L15-20 notifier/describe.go• L45-89 notifier/describe.go• L91-119 notifier/…/notifier.go• L84-145 notifier/…/notifier_test.go• L227-259 notifier/…/should_call_webhook_and_have_valid_results.json• L4-29 notifier/…/notifier.go• L88-190 notifier/…/notifier_test.go• L279-393 notifier/…/should_call_webhook_and_have_valid_results.json• L2-16 notifier/…/notifier.go• L39-82 notifier/…/notifier_test.go• L216-222 notifier/…/should_call_webhook_and_have_valid_results.json• L19-23

Webhook delivery

The generic webhook sends an HTTP POST with JSON that contains optional metadata and the complete DiffCache. The payload preserves added, deleted, and updated flag values, which lets a receiving service make its own decision about the change.

The webhook preserves configured custom headers and sets Content-Type to application/json. It creates a separate header set for each request, so concurrent notifications do not change one another or the notifier configuration. When a secret is configured, the notifier signs the exact JSON body with X-Hub-Signature-256; this generated value takes precedence over a configured value for that header.

References: notifier/…/notifier.go• L20-24 notifier/…/notifier.go• L71-85 notifier/…/notifier.go• L118-155 notifier/…/notifier_headers_test.go• L23-137

Configuration model

The SDK accepts a list of notifiers in Config.Notifiers. The SDK also adds its log notifier as a built-in channel, so configured channels and logs receive the same change event.

Multiple notifiers are supported at the same time. The list is useful when a change must reach both people and systems, such as a chat room for operators and a webhook for automation.

Each destination must provide the information required by its channel. Missing endpoint settings or rejected HTTP responses become notifier errors and are written to the SDK log; they do not cancel the cache update.

References: config.go• L67-68 feature_flag.go• L86-90 notifier/…/notifier.go• L41-79 notifier/…/notifier.go• L88-152

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to notifier.DiffCache must remain compatible with every built-in notifier and with webhook consumers that read the JSON field names.
  • Changes to field-level diff formatting must preserve stable paths, readable before-and-after values, and the failure label used by chat payloads.
  • Changes to semantic change descriptions must cover every exported flag field and preserve rule and scheduled-step pairing.
  • Changes to cache replacement or refresh ordering must preserve the old-versus-new snapshots used to classify added, deleted, and updated flags.
  • Changes to initial-load or offline behavior must preserve the intended notification suppression rules.
  • Changes to notifier concurrency or shutdown must preserve the wait guarantee so delivery work is not abandoned when the SDK closes.
  • Changes to a chat payload must account for destination size limits, Markdown escaping, destination-specific ordering, and the log path used for the full change list.
  • Changes to webhook headers or signing must preserve per-request header isolation, JSON content type, and signature coverage of the exact request body.

Important failure modes

TriggerConsequenceGuard
A notifier has no required webhook URL.That destination returns an error and the error is logged.Set the channel endpoint before adding the notifier to Config.Notifiers.
A webhook endpoint rejects the request or the HTTP call fails.The destination does not receive the change, while the cache and other notifiers continue.Monitor SDK error logs and make the endpoint available.
A configured webhook header map is reused across concurrent requests.One request can change another request's headers or the notifier's configuration.Build each request from an isolated header copy and verify the signature against that request's body.
DisableNotifierOnInit is left false during a service restart.The initial configuration can produce an alert for every loaded flag.Enable the setting when startup alerts are not useful.
Many flags change in one refresh.Chat output can be shortened, especially in Discord.Use logs or the generic webhook for the complete diff.
A flag contains a value that the semantic change describer cannot handle.Updated chat output marks the change detail as unavailable.Keep the flag in the supported internal flag form and inspect the error text in the notification.
A flag format adds a field without a matching semantic description.That field can change without a useful human-readable entry.Update the change describer and its field coverage check with the flag model.
A Slack change value contains a mention or link marker.Slack can interpret the value as a control sequence instead of flag data.Keep Slack escaping in the message path.
The SDK runs in more than one instance.Each instance can report the same source change.Use the host metadata in notifications to identify the reporting instance.

Key files

FileWhy to read it
internal/…/notification_service.goShows the boundary between cache snapshots, diff creation, fan-out, error logging, and shutdown.
notifier/diff_cache.goDefines the shared change record passed to every delivery channel.
notifier/changelog.goDefines the field-level change view and readable value format used by structured diff consumers.
notifier/describe.goDefines the human-readable change language used by chat delivery.
notifier/notifier.goDefines the notifier extension contract.
internal/…/cache_manager.goShows when the active cache changes and when notification comparison starts.
retriever/manager.goShows how startup, polling, and explicit refreshes decide whether to notify.
config.goDefines the application-facing notifier list and startup suppression option.
notifier/…/notifier.goShows the structured webhook payload and optional signing contract.
notifier/…/notifier_headers_test.goShows that custom headers remain intact and concurrent signed requests keep separate signatures.
notifier/…/notifier.goShows the Slack message representation, escaping, and webhook delivery.
notifier/…/notifier.goShows the Discord message representation and size handling for large change sets.
notifier/…/notifier.goShows the plain-text Adaptive Card message representation for Microsoft Teams.
notifier/…/notifier.goShows the local log event meanings for each change category.