Rewrite client-side feature flags guide with OFREP gotchas#1868
Open
Rewrite client-side feature flags guide with OFREP gotchas#1868
Conversation
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.
Deploying logfire-docs with
|
| 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 |
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.
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:
baseUrlwas documented as\${apiHost}/v1/ofrep/v1, but@openfeature/ofrep-web-providerappends/ofrep/v1/evaluate/flagsitself. Passing the full OFREP path produces a doubled URL and 404s. Correct snippet + pitfall callout.contextfield with 422, which marks the OFREP provider fatally errored. Document the requirement and recommend seeding the context on provider registration.fetchImplementationexample was dropping the library'sContent-Type: application/jsonheader (another 422). Show the correct header-merging pattern.FLAG_NOT_FOUNDlookup has an obvious first place to check.useContextMutatorfor auth-driven context updates instead of callingOpenFeature.setContextdirectly.Test plan
uv run mkdocs buildsucceeds (pre-existing mkdocstrings warnings unrelated)./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.