Skip to content

fix: report not ready without flags, and reject unusable configuration - #23

Open
lourens-octopus wants to merge 1 commit into
mainfrom
lourens/behaviour-fixes
Open

lourens-octopus wants to merge 1 commit into
mainfrom
lourens/behaviour-fixes

Conversation

@lourens-octopus

@lourens-octopus lourens-octopus commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Resolves BMBB-1565.

What

Fixes three behaviour issues from the Python provider 0.1.0 review. The review's flags freeze issue isn't included.

Without any fetched flags, evaluations report PROVIDER_NOT_READY

With a wrong client identifier, the server returns 404 and set_provider_and_wait still succeeds. Every flag then returned FLAG_NOT_FOUND, and every flag logged a warning to "double check your slug". The real cause, that no flags were ever fetched, showed up only as one warning at startup.

This follows the TypeScript providers (requireEvaluator in packages/server/src/octopusFeatureProvider.ts). Until a fetch succeeds (the evaluator's content hash is empty), boolean and non-boolean evaluations raise ProviderNotReadyError with the same message: "No Octopus feature flags are available. The provider failed to initialize, or was used before initializing." The slug warning is no longer logged in that state.

  • The SDK still reports the provider as READY, and polling keeps retrying every cache_duration.
  • A successful fetch with zero flags still gives FLAG_NOT_FOUND.

This reverses what BMBB-1515 asked for. .NET, Go and Java still return FLAG_NOT_FOUND here, and matching them up has no ticket yet.

Header values are stripped and validated

The emptiness check on client_identifier stripped whitespace, but the request used the value unstripped. A trailing newline, which is common when the value is read from a file or a mounted secret, made httpx raise LocalProtocolError: Illegal header value on every request. release_version_override wasn't validated at all.

The constructor now strips both values. It raises ValueError if a value is empty or contains anything other than printable ASCII, and TypeError if it isn't a str.

http_client must be an httpx.Client

Passing an httpx.AsyncClient made every request fail with AttributeError: 'coroutine' object has no attribute 'status_code' and a "coroutine was never awaited" warning. The constructor now raises TypeError.

Testing

  • Updated the tests that expected FLAG_NOT_FOUND after a failed fetch.
  • Added tests for:
    • the 404 and 500 cases, including that no slug warning is logged
    • evaluation before initialization
    • an empty manifest
    • stripped values being sent in the request headers
    • rejected header values and rejected async clients
  • uv run ruff check && uv run ruff format --check && uv run mypy && uv run pytest: 433 passed.
  • The README describes the new behaviour.

🤖 Generated with Claude Code

- Until a fetch succeeds, every evaluation reports PROVIDER_NOT_READY with
  the TypeScript provider's message, instead of FLAG_NOT_FOUND and a warning
  blaming the slug. A wrong client identifier no longer looks like a typo in
  every flag key.
- Strip whitespace around client_identifier and release_version_override, and
  reject values that still can't be sent in an HTTP header. A trailing newline
  from a file or mounted secret made every request fail.
- Reject an http_client that isn't an httpx.Client. An httpx.AsyncClient made
  every request fail with an un-awaited coroutine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lourens-octopus
lourens-octopus requested a review from a team as a code owner November 25, 2026 23:38
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.

1 participant