Skip to content

docs: make a custom System One base URL obvious - #5

Merged
codeitlikemiley merged 2 commits into
mainfrom
gol/custom-base-url
Sep 24, 2026
Merged

codeitlikemiley merged 2 commits into
mainfrom
gol/custom-base-url

Conversation

@codeitlikemiley

Copy link
Copy Markdown
Owner

Callers could already override the host, but docs and examples hid it. Reject a blank or non-http URL at build, add a mock example, and record mock-HTTP bench numbers. No hot-path change.

Callers could already override the host, but docs and examples hid it.
Reject a blank or non-http URL at build, add a mock example, and record
mock-HTTP bench numbers. No hot-path change.

Co-authored-by: hexuria <hexuria@users.noreply.github.com>

@codeitlikemiley codeitlikemiley left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment. No code change requested.

The override works. normalize_base_url runs once inside Config::resolve at build. system_one and models both use format!("{}{path}", config.base_url). The only src/ change is src/config.rs. Auth, JSON body, retry, and timeout stay as they are when build succeeds.

Checked on 9a17634 with rustc 1.98.1. cargo test --lib config:: passed (trailing slash and whitespace, blank, ftp, relative). custom_base_url_serves_system_one_and_models and same_origin_307_is_followed passed with --features mock.

Not blocking.

  • A base URL that contains ? or # is accepted. The join is still string append, so /v1/systemone lands in the query or the fragment. That join is unchanged from main. Rejecting those strings at build would be new policy.
  • docs/audit-2026-09-24.md says the example locks a path prefix. The contract test does (/gateway/v1/...). examples/custom_base_url.rs mounts /v1/systemone and /v1/models on the wiremock origin.
  • examples/README.md now says live mode uses TYPESAFE_BASE_URL or else https://api.typesafe.ai. custom_base_url returns Error::Sdk when that variable is unset. The other examples still fall back.
  • Common failure 10 says the base URL is the server root. README and the contract test also allow a path prefix such as /gateway.
  • The runnable example does not call .model(). The README and AGENTS snippets do. Live mode therefore sends jev-latest.
  • The audit says no example called .base_url before this PR. examples/support/harness.rs and examples/blocking_triage.rs already did, against wiremock.
  • Bench numbers in the audit were not reproduced here. The harness binds wiremock on 127.0.0.1, disables retries, and does not read TYPESAFE_API_KEY. CI compiles the bench and does not run it.
  • An accepted http or https URL still matches the Python 0.6.0 string join. Rust now rejects an empty or non-http(s) base at build. Python 0.6.0 only does rstrip("/").

No Bugbot threads. New module-doc comments are not a reason to change the code.

Path prefixes stay allowed and are locked by the contract test, not the example. Live custom_base_url requires TYPESAFE_BASE_URL and sets jev-latest explicitly. Docs warn that query, fragment, and a trailing /v1 are joined as text.

Co-authored-by: hexuria <hexuria@users.noreply.github.com>
@codeitlikemiley
codeitlikemiley merged commit 69818d7 into main Sep 24, 2026
10 checks passed
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.

2 participants