Skip to content

Default base_url from PROOFLINE_BASE_URL - #61

Open
usaamahahmed101 wants to merge 1 commit into
prooflinedev:mainfrom
usaamahahmed101:base-url-from-environment
Open

usaamahahmed101 wants to merge 1 commit into
prooflinedev:mainfrom
usaamahahmed101:base-url-from-environment

Conversation

@usaamahahmed101

Copy link
Copy Markdown

What changes

base_url is now optional on ProoflineClient and AsyncProoflineClient. When it is left out, the clients read PROOFLINE_BASE_URL, and when that is not set they use https://proofline.sh.

The order is: the base_url argument, then a non-empty PROOFLINE_BASE_URL, then the hosted origin.

from proofline import ProoflineClient

# PROOFLINE_TOKEN and PROOFLINE_BASE_URL come from the environment
with ProoflineClient() as client:
    ...

Who it helps

Anyone who points a script or CI job at something other than the hosted origin, such as a staging or dedicated deployment. The CLI (--base-url, env PROOFLINE_BASE_URL), the MCP bridge and, since prooflinedev/sdk-typescript#50, the TypeScript SDK all read this variable. The Python SDK already reads PROOFLINE_TOKEN from the environment but hard-coded the origin. So a team that sets the variable once for the CLI in CI still had to thread the same value through its Python code, and a script that forgot to do so silently talked to production.

Decisions

  • An explicit base_url wins over the variable. A program that names its origin should not change behaviour because of the shell it runs in.
  • An empty PROOFLINE_BASE_URL counts as unset. A CI template that expands a missing variable to an empty string gets the hosted origin, not a startup error.
  • The variable goes through the same origin checks as the argument (HTTPS, or HTTP on a literal loopback address; no credentials, path, query or fragment). A bad value raises a ValueError starting with PROOFLINE_BASE_URL must be, so it is clear which setting to fix. The message never repeats the value, because https://user:secret@host would otherwise end up in logs. A bad base_url argument keeps its existing message.
  • The resolution lives in one helper, _transport.configured_base_url, used by both clients, so sync and async cannot drift.
  • scripts/check.py removes PROOFLINE_BASE_URL from the test environment, as it already does for PROOFLINE_TOKEN. A developer who has the variable exported locally still gets hermetic runs.

There is no change to the generated code, the OpenAPI contract, retries, timeouts or the package version.

Verification

  • Added test_base_url_defaults_to_the_environment_then_the_hosted_origin (sync and async) using the existing loopback Server fixture. It covers: a client without base_url sends the request and token to PROOFLINE_BASE_URL; an explicit base_url wins; unset and empty both fall back to https://proofline.sh; and bad values (including one with credentials) are refused by name without echoing the secret.
  • Ran the new test against main first: both cases fail ('https://proofline.sh' == 'http://127.0.0.1:…'). With this change they pass.
  • Full local check: ruff check, ruff format --check, mypy proofline scripts, and pytest: 218 passed.

🤖 Generated with Claude Code

ProoflineClient and AsyncProoflineClient now take base_url=None. When it is
left out they read a non-empty PROOFLINE_BASE_URL, and otherwise use
https://proofline.sh, matching the CLI, the MCP bridge and the TypeScript
SDK. An explicit base_url wins; an empty variable counts as unset; a bad
value is refused by name without echoing it. check.py drops the variable
from the test environment like PROOFLINE_TOKEN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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