Skip to content

fix: don't require api_url/api_key in local mode#8

Merged
Polliog merged 1 commit into
mainfrom
fix/local-mode-no-endpoint-required
Jul 17, 2026
Merged

fix: don't require api_url/api_key in local mode#8
Polliog merged 1 commit into
mainfrom
fix/local-mode-no-endpoint-required

Conversation

@Polliog

@Polliog Polliog commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #7, as flagged in the review there.

The api_url check added in cdac5d0 ran unconditionally and sat before the local_mode logic, so:

ClientOptions(local_mode=True)   # -> ValueError: api_url must be provided

That defeats the point of local mode. A client that never touches the network had to be handed an endpoint it would never use, since log() returns early anyway. The existing tests didn't catch it because they all pass an api_url.

Both endpoint checks are now gated on local_mode being off. Also removed the duplicate guard in BaseClient.__init__, which raised RuntimeError for the missing-key case that __post_init__ already rejects with ValueError (unreachable, and a second exception type for the same condition).

Behavior now:

construction result
ClientOptions(local_mode=True) OK, no endpoint needed
ClientOptions(local_mode="if_unset_api_key") OK, no endpoint needed
ClientOptions(api_key="lp_k") ValueError: api_url must be provided
ClientOptions(api_url="http://x:8080") ValueError: api_key must be provided...

Added a parametrized test covering local mode with nothing configured.

Suite: 138 passed, 8 skipped. The 2 failures in tests/middleware/test_imports.py are pre-existing on main and unrelated.

The api_url check ran unconditionally and before the local_mode logic, so
ClientOptions(local_mode=True) raised "api_url must be provided". That
defeats the purpose of local mode: a client that never reaches the network
had to be handed an endpoint it would never use.

Gate both endpoint checks on local_mode being off. Also drop the duplicate
guard in BaseClient.__init__, which raised RuntimeError for the missing-key
case that __post_init__ already rejects with ValueError.
@Polliog
Polliog merged commit ba2ff5a into main Jul 17, 2026
5 checks passed
@Polliog
Polliog deleted the fix/local-mode-no-endpoint-required branch July 17, 2026 11:37
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