Page 5 of 8~112 min topic

Feature flags lab

Design retries, degradation, and recovery

When browser-exposed flag lets attackers force v2 (unreviewed) index, the system must degrade on purpose without widening blast radius.

~14 min this pageFailure handling

1Try it yourself

Decision drill

Feature flag lab

Flags control who sees what — without redeploying code.

Release control72%

1/3New RAG index for 5% of traffic.

2Learn the idea

Read

Classify and bound retries

Map failure classes for POST /v1/rag/answer: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to flag writes require RBAC; client-supplied flag values never authorize access. The chapter’s signature failure — browser-exposed flag lets attackers force v2 (unreviewed) index — must take a deliberate branch, not a generic catch-all.

Read

Containment path

Implement the degrade/rollback/refuse behavior release captain flipping rag_index_v2 for cohort canary needs when FLAG-CLIENT-TRUST-4 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”

Read

Implementation artifact

flags.set("rag_index_v2", False, reason="citation_regression", actor="release-captain")

Read

Verify harm reduction

After containment, check flag_exposure_pct and citation_delta_v2_vs_v1 moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.

Read

Stage depth

Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how browser-exposed flag lets attackers force v2 (unreviewed) index becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for flag_exposure_pct and citation_delta_v2_vs_v1.

Read

Field notes for `feature-flags-lab` / `failure-handling`

Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. In this chapter the product is FastAPI RAG endpoint whose v2 index is dark-launched then exposed to 5%, the human stakeholder is release captain flipping rag_index_v2 for cohort canary, and the incident id you design against is FLAG-CLIENT-TRUST-4. Re-state the oracle in your notes — 5% cohort sees index_v2 citations; kill switch returns everyone to v1 in < 60s — and keep the invariant visible: flag writes require RBAC; client-supplied flag values never authorize access. Track flag_exposure_pct and citation_delta_v2_vs_v1 as the scoreboard. Surface under change control: POST /v1/rag/answer. If you only have forty minutes, finish the fixture for browser-exposed flag lets attackers force v2 (unreviewed) index before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.

Go deeper

Before you start

Why this matters

Assume browser-exposed flag lets attackers force v2 (unreviewed) index is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: flag writes require RBAC; client-supplied flag values never authorize access.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Are retry budgets explicit?
2. Is containment scoped?
3. Do you preserve evidence for FLAG-CLIENT-TRUST-4?

All responses are required.