Skip to content

fix(config): the URL resolver defaulted to the internal host, defeating #78 - #82

Merged
trentleslie merged 1 commit into
devfrom
fix/resolver-default-matches-public
Aug 24, 2026
Merged

trentleslie merged 1 commit into
devfrom
fix/resolver-default-matches-public

Conversation

@trentleslie

Copy link
Copy Markdown
Collaborator

The bug

With KESTREL_API_URL unset, dev resolves the Kestrel backend to the internal host. #78's public-default promotion, merged an hour ago, is currently cosmetic.

$ env -u KESTREL_API_URL uv run python -c "..."    # on dev @ 3b8d6bd
config.KESTREL_API_URL  (constant) : https://kestrel.krakenkg.com/api
get_kestrel_api_url()   (resolver) : https://kestrel.nathanpricelab.com/api
AGREE? False

The client resolves through the function, so the function's answer is the one that ships.

Why it happened

Two independent readings of one setting:

source default
config.KESTREL_API_URL os.getenv(..., PUBLIC_KESTREL_API_URL) public
get_kestrel_api_url() os.environ.get(..., _DEFAULT_KESTREL_API_URL) internal

get_kestrel_api_url() arrived in #74 with its own hardcoded fallback — correct then, because the repo default was internal. #78 promoted the default by moving the constant. Nothing tied the two together, so they silently diverged.

This is a consequence of the #78 rebase I did: that rebase resolved bulk_kestrel_request onto the resolver (per #79's adjudication, and necessary — the credential guard has to judge the URL the request actually goes to). Correct on its own terms, but it made the resolver's stale fallback load-bearing, and I did not check that the two defaults matched. Caught while merging dev down into the fork.

The fix

Drop _DEFAULT_KESTREL_API_URL; the resolver falls back to PUBLIC_KESTREL_API_URL. One place decides the default.

Env override unaffected — KESTREL_API_URL=... still wins, and --kestrel-url still reaches the client after import (verified both).

Test

test_the_constant_and_the_resolver_share_one_default asserts the two agree under a cleared environment (reimporting config, since the constant is import-time state). Verified it fails on pre-fix code:

AssertionError: assert 'https://kestrel.nathanpricelab.com/api' == 'https://kestrel.krakenkg.com/api'

Verification

ruff clean · black clean · pyright 0 errors · test-fast.sh 303 passed, 62 deselected

🤖 Generated with Claude Code

…he constant

With KESTREL_API_URL unset, config.KESTREL_API_URL returned the PUBLIC host while
get_kestrel_api_url() returned the INTERNAL one. The client resolves through the
function, so dev has been defaulting to kestrel.nathanpricelab.com since #78
merged -- the public-default promotion that #78 exists to deliver was cosmetic.

Two independent readings of one setting. get_kestrel_api_url() was added by #74
with its own hardcoded fallback, correct at the time because the repo default WAS
internal. #78 promoted the default to public by moving the constant, and nothing
connected the two, so they silently disagreed. Drop the private
_DEFAULT_KESTREL_API_URL and fall back to PUBLIC_KESTREL_API_URL, leaving exactly
one place that decides the default.

Env override is unaffected: KESTREL_API_URL=... still wins, and --kestrel-url
still reaches the client after import.

Adds a test asserting the constant and the resolver agree under a cleared
environment. Verified it fails against the pre-fix code with
'https://kestrel.nathanpricelab.com/api' != 'https://kestrel.krakenkg.com/api'.

ruff clean, black clean, pyright 0 errors, 303 passed / 62 deselected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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