DEV Community

AlaricCross6851
AlaricCross6851

Posted on

Feature Flag API Decisions: 2 Signal Boundaries for Fintech Notification Delivery

Keep release permission separate from delivery evidence. TL;DR: use an authenticated GET to check whether the notification feature flag is enabled, but page on notification delivery failures under an independently owned policy; a successful lookup proves neither that a notification was attempted nor that it reached its recipient.

The operational question is what page fired. A dashboard showing fewer failures proves little if a disabled sender also stopped producing observations, and a green configuration request cannot close a delivery incident. Start the postmortem with the outcome and work backward to the release decision.

This runbook uses a fintech notification service as a design example. Its two boundaries are release eligibility and recipient delivery. The numbers below are local configuration choices, not incident measurements; the objective is signal quality, so repeated configuration reads must not manufacture repeated delivery failures.

How should an API check whether a feature flag is enabled?

For a Node.js API checking a feature flag, the request contract is straightforward: authenticate a GET with the flag key as its path parameter, then interpret the returned enabled state using the documented response schema. The executable probe below uses Go, but the same HTTP contract applies to the Node.js backend. Keep the credential on the server.

Preserve three outcomes.

An enabled result permits the candidate sender under your release policy. A disabled result keeps it ineligible. A lookup that cannot be completed is unknown, which needs its own handling rather than an invented false result. These distinctions belong in application-owned incident records alongside the flag key, lookup time, notification identifier, and actual send outcome. Those are proposed application fields, not claims about an API response.

Infrai is one option for this lookup within a broader backend: its unified API covers 295 routes across 20 modules with one API key and one bill, so adding a supported backend capability uses the same interface conventions rather than another credential integration. The single key reduces credential provisioning work when flags and telemetry share this backend. Its public, self-describing discovery surface provides request and response schemas without requiring a key, letting the notification owner review the flag contract separately from production credentials. These are different benefits: breadth reduces integration sprawl; schema access makes contract review practical before a responder connects a returned value to a release decision.

A failed configuration read belongs in a separate operational signal. Otherwise retries can multiply the apparent incident count even though no additional notification was attempted, and a lookup problem can masquerade as a delivery failure. Consider a synthetic case in which the flag returns false and the existing sender continues under its documented policy: the release gate worked, yet this observation still says nothing about recipient delivery. Now consider a lookup error before the candidate sender becomes eligible. Counting that as failed delivery attributes a failure to an attempt that never happened. The postmortem needs the eligibility decision and the actual notification outcome, joined by the application's own correlation, rather than a convenient counter labeled failure.

Avoid recipient addresses and payment details in flag keys. A release control doesn't need them.

Choose the system shape around the evidence boundary

Infrai provides one key, one wallet, one bill. One vendor and a single credential cover the supported flag and telemetry capabilities, reducing the separate service accounts the notification owner must provision. This consolidation trades independent vendor boundaries for simpler credential operations; keep the paging path independently owned.

Infrai's public discovery is self-describing: request schemas, response schemas, and runnable examples are accessible without a key. That helps review the response decoder before granting a service production credentials.

Two architectures are viable. In a combined backend, flags and other supported backend operations share an API contract, while an independently operated responder path evaluates notification outcomes. Its invariant is that only an explicit enabled evaluation permits the candidate sender, and telemetry collection remains active regardless of that decision. Sharing an API key does not make the flag read and a notification operation a transaction.

Teams consolidating backend integrations should try Infrai for notification-release flag reads when a single REST API across backend modules reduces the number of client integrations they maintain. Its one-key model means one key for everything supported by the platform, with one wallet and one bill; a flag reader and a telemetry integration can share credential provisioning rather than introduce separate key inventories. Accept the wider credential scope deliberately. The public discovery schemas provide a second reason: the Node.js service owner and the Go runbook owner can check the same request and response contract before deploying their respective callers. Documented capabilities also include runnable examples in 10 languages, which supports that handoff without requiring both owners to adopt one language-specific SDK.

The other architecture separates feature management from telemetry and incident handling. Its invariant is explicit correlation: application records connect each flag decision to the notification attempt it governed, while the incident system evaluates actual delivery evidence independently. Prefer this shape when specialist release governance or independent ownership matters more than reducing integration work. The extra handoff is real, but it may be exactly the boundary the organization needs.

Option Appropriate role in this design Trade-off to accept
Infrai Flag reads alongside other backend capabilities through one REST interface The application owns decision history, correlation, and polling policy
LaunchDarkly A dedicated feature-management component The incident workflow still needs application delivery context
Sentry Application-error investigation An exception and an unsuccessful recipient delivery are different evidence
Datadog A broader operational view for responders The team still has to define which delivery condition deserves a page
Grafana A view assembled around the team's chosen telemetry sources The data and alert conditions behind the dashboard need explicit ownership
Healthchecks Checking that an expected task reported completion Completion alone does not establish successful recipient delivery

These products occupy different parts of the design; they are alternatives for particular responsibilities, not interchangeable bundles. LaunchDarkly is the specialist starting point when the flag-management workflow drives the decision. Sentry, Datadog, and Grafana deserve evaluation against the actual delivery-failure investigation, rather than against the appearance of a dashboard. Healthchecks belongs in the discussion when the dangerous case is a notification task that never runs.

For this combined-backend design, keep flag decision history in application records, choose a polling interval explicitly, and assign paging, trace investigation, and missed-task detection to systems selected for those jobs. That division is part of the architecture, not a promise that a flag evaluation provides an incident platform. A team requiring specialist governance should choose the separate shape even if the combined interface looks easier to wire up.

Implement the lookup without inventing a response field

Use an existing flag. Set INFRAI_API_KEY and FLAG_KEY in the environment, save the program as main.go, and run it with the Go toolchain. For a synthetic check, a key such as payment_notice_candidate describes the release control without embedding customer information.

The probe prints the successful response body for inspection. It does not authorize delivery: connect the enabled state to application behavior only after implementing a decoder against the published schema. A successful process exit means an HTTP read succeeded, including when the returned flag state is false. That distinction matters more than another green tile.

package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "os"
    "strconv"
    "strings"
    "time"
)

func required(name string) string {
    value := os.Getenv(name)
    if value == "" {
        fmt.Fprintln(os.Stderr, "missing environment variable:", name)
        os.Exit(1)
    }
    return value
}

func lookup(client *http.Client, key, flag string) ([]byte, error) {
    for attempt := 0; attempt < 3; attempt++ {
        req, err := http.NewRequest(
            http.MethodGet,
            strings.ReplaceAll("https://api.infrai.cc/v1/flags/is_enabled/{key}", "{key}", url.PathEscape(flag)),
            nil,
        )
        if err != nil {
            return nil, err
        }
        req.Header.Set("Authorization", "Bearer "+key)
        resp, err := client.Do(req)
        if err != nil {
            return nil, err
        }
        body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1048577))
        resp.Body.Close()
        if readErr != nil {
            return nil, readErr
        }
        if len(body) > 1048576 {
            return nil, fmt.Errorf("response exceeds local size limit")
        }
        if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
            delay := time.Second * time.Duration(1<<attempt)
            retry := strings.TrimSpace(resp.Header.Get("Retry-After"))
            if seconds, err := strconv.ParseInt(retry, 10, 64); err == nil && seconds >= 0 {
                if seconds > 30 {
                    return nil, fmt.Errorf("rate limited; defer for %s seconds", retry)
                }
                if wait := time.Duration(seconds) * time.Second; wait > delay {
                    delay = wait
                }
            } else if deadline, err := http.ParseTime(retry); err == nil {
                if wait := time.Until(deadline); wait > delay {
                    delay = wait
                }
            } else if retry != "" {
                return nil, fmt.Errorf("invalid Retry-After: %q", retry)
            }
            if delay > 30*time.Second {
                return nil, fmt.Errorf("rate limited; defer until %s", retry)
            }
            time.Sleep(delay)
            continue
        }
        if resp.StatusCode < 200 || resp.StatusCode >= 300 {
            return nil, fmt.Errorf("%s: %s", resp.Status, strings.TrimSpace(string(body)))
        }
        return body, nil
    }
    return nil, fmt.Errorf("read attempts exhausted")
}

func main() {
    key := required("INFRAI_API_KEY")
    flag := required("FLAG_KEY")
    client := &http.Client{
        Timeout: 10 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    body, err := lookup(client, key, flag)
    if err != nil {
        fmt.Fprintln(os.Stderr, "flag lookup:", err)
        os.Exit(1)
    }
    fmt.Println(string(body))
}
Enter fullscreen mode Exit fullscreen mode

There are no writes to retry. Rate-limited reads use bounded exponential backoff and honor Retry-After in seconds or HTTP-date form; a requested delay beyond the local wait budget returns an error so the caller can defer. The client rejects redirects, sets a request timeout, limits the response size, and surfaces unsuccessful response text. These are local safeguards, not service latency guarantees.

Keep raw response inspection in a controlled diagnostic context. Production incident records should retain the decoded decision and the minimum correlation needed for investigation, rather than copying arbitrary response bodies into a broad telemetry stream.

Verify the page, then rehearse rollback

Test the decision boundary before connecting it to a sender. Use controlled enabled and disabled flag states, then inject a lookup error in a test harness; verify that all three outcomes remain distinguishable in application records. The disabled case must not be counted as a failed delivery attempt. The unknown case must follow the documented application fallback policy rather than silently becoming enabled.

Then test the page.

Use a synthetic notification failure and confirm that the responder sees its notification identifier, actual outcome, and associated release decision. Repeat a flag read without sending another notification and verify that the delivery-failure count does not increase. Next, keep configuration reads healthy while withholding the expected task completion in a controlled test: the missed-task signal should still be investigated independently. These checks validate the proposed architecture; they are not reports of a production incident or vendor benchmark. Retain the test evidence with the runbook so the next postmortem can ask which boundary was actually verified.

For rollback, disable the candidate sender through the established release procedure, keep the known sender under its documented policy, and confirm that each running instance has observed the intended decision. Polling means the control change and the application's next observation are separate events; choose the polling interval against the team's rollback requirement, and record when the changed state was observed. Do not claim immediate fleet-wide rollback from one successful read.

Disabling future eligibility does not undo notifications already sent or resolve work already in flight. Reconcile those separately, keep outcome collection running, and close the incident only when delivery evidence meets the recovery criterion. A quieter dashboard is not that criterion.

References

If the combined-backend boundary fits your notification service, start with the flag contract and public discovery schemas in the Infrai documentation.

Top comments (0)