Errors and fallbacks
Handle startup, refresh, authentication, missing flags, and stale configuration safely.
Every evaluation has two fallback layers: the environment fallback and the caller default. They solve different problems and should be chosen deliberately.
The environment fallback is normal configuration when no targeting group matches. The caller default is application policy when FeatureGate cannot resolve a valid typed value.
The caller default applies when a flag is:
Missing targeting context is different. A condition misses, evaluation continues to later groups, and the configured environment fallback wins if no group matches.
An active kill switch is also not an error. Its emergency value wins before rules and fallback.
Choose a default for the failure mode, not merely the most common value. Ask what the application should do when configuration is missing, the network is unavailable, or a deployment contains an old key.
For a release, the existing behaviour is often safest. For an operational control, the safe state depends on whether failure should preserve service or stop risky work.
Do not use a default to hide integration failure indefinitely. Details getters and application monitoring should reveal sustained use of defaults during startup or hosted failure.
initialize() rejects when the first remote snapshot cannot be loaded or validated. Decide whether
the process should:
Do not catch and ignore initialization errors without selecting one of these policies.
Explicit refresh() rejects with a typed error. Automatic polling reports failures through onError.
After a successful load, both leave the last valid snapshot available.
Monitor the age of the last successful refresh. A client that continues evaluating is not necessarily current. Repeated authentication errors usually require key rotation rather than retry.
| SDK error | Meaning | Response |
|---|---|---|
FeatureGateAuthenticationError | Key rejected with 401 or 403 | Inspect key, scope, and organisation state |
FeatureGateConfigurationError | Options or snapshot are invalid | Correct configuration before retry |
FeatureGateRequestError | Timeout, rate limit, network, or 5xx | Preserve safe state and retry only when bounded |
| Status | Action |
|---|---|
400 | Correct request shape, duplicate keys, context, or types |
401 | Replace a missing, malformed, unknown, or revoked key |
403 | Check family, scope, origin, exposure, binding, and lifecycle |
413 | Reduce body, batch, or context size |
429 | Respect retry information and reduce pressure |
5xx | Use defaults and retry with bounded backoff if latency permits |
WORKSPACE_OFFBOARDING is the stable compatibility code for an organisation in its export window or
deletion-pending state. Credential rotation does not bypass organisation lifecycle enforcement.
Record request ID, time, route, status, key prefix, project, environment, and error class. Never log raw keys, authorization headers, cookies, full context, request bodies, targeting values, or resolved values.
Related pages: Troubleshooting and limits, Snapshots and freshness, and Evaluation credentials.