Skip to content

Rewrite client-side feature flags guide with OFREP gotchas#1868

Open
Kludex wants to merge 1 commit intomainfrom
marcelo/improve-ofrep-docs
Open

Rewrite client-side feature flags guide with OFREP gotchas#1868
Kludex wants to merge 1 commit intomainfrom
marcelo/improve-ofrep-docs

Conversation

@Kludex
Copy link
Copy Markdown
Member

@Kludex Kludex commented Apr 17, 2026

Summary

Docs-only rewrite of client-side-feature-flags based on hands-on use of the page while wiring a managed-variable flag into the Logfire frontend. Several bits cost real time:

  • baseUrl was documented as \${apiHost}/v1/ofrep/v1, but @openfeature/ofrep-web-provider appends /ofrep/v1/evaluate/flags itself. Passing the full OFREP path produces a doubled URL and 404s. Correct snippet + pitfall callout.
  • Backend rejects evaluations without a context field with 422, which marks the OFREP provider fatally errored. Document the requirement and recommend seeding the context on provider registration.
  • The fetchImplementation example was dropping the library's Content-Type: application/json header (another 422). Show the correct header-merging pattern.
  • Prerequisites now call out the External toggle and the "no version published yet" case so a FLAG_NOT_FOUND lookup has an obvious first place to check.
  • React-SDK section now recommends useContextMutator for auth-driven context updates instead of calling OpenFeature.setContext directly.
  • Added a debugging table mapping symptoms (FLAG_NOT_FOUND / 422 / 404 / 401 / stale value / reason: DEFAULT) to causes and fixes, plus a raw-fetch snippet for isolating backend vs SDK issues.

Test plan

  • uv run mkdocs build succeeds (pre-existing mkdocstrings warnings unrelated).
  • Every claim in the rewrite is backed by the Logfire SaaS endpoint behaviour at time of writing (/v1/ofrep/v1/evaluate/flags → 401 with correct auth; doubled-prefix path → 404).

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I take full ownership of it.

Based on hands-on use of the page to migrate an `agent_runs` flag in
the Logfire frontend, several things in the walkthrough cost real time:

- `baseUrl` was shown as `${apiHost}/v1/ofrep/v1`, but the OFREP provider
  library appends `/ofrep/v1/evaluate/flags` itself - passing the full
  OFREP path doubles it and produces 404s. Correct it to `${apiHost}/v1`
  and add a pitfall callout.
- The backend rejects evaluation requests without a `context` field with
  a 422, and the OFREP provider marks itself fatally errored on that.
  Spell out the requirement and recommend `setProviderAndWait(provider,
  { targetingKey: 'anonymous' })` or gating registration on auth.
- The `fetchImplementation` snippet dropped the `Content-Type:
  application/json` header the library sets on the `Request` object,
  which also produces a 422. Show the correct header-merging pattern.
- External toggle + "no version yet" are easy to miss - call them out
  in Prerequisites so FLAG_NOT_FOUND doesn't send readers hunting.
- Recommend `useContextMutator` inside a React app rather than calling
  `OpenFeature.setContext` directly, so the React-SDK hooks re-render.
- Add a debugging table mapping symptoms (`FLAG_NOT_FOUND`, 422, 404,
  401, stale value, `reason: DEFAULT`) to causes and fixes, plus a raw
  `fetch` snippet for isolating backend vs SDK issues.

No behaviour changes - this is a docs-only improvement.
@Kludex Kludex self-assigned this Apr 17, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6c436ac
Status: ✅  Deploy successful!
Preview URL: https://6afdc649.logfire-docs.pages.dev
Branch Preview URL: https://marcelo-improve-ofrep-docs.logfire-docs.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@Kludex Kludex assigned dmontagu and unassigned Kludex Apr 17, 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.

2 participants