Skip to main content

Module base_override

Module base_override 

Source
Expand description

The DOIGET_*_BASE test / proxy overrides, as one table (#587).

Every fetch source honours a DOIGET_<SOURCE>_BASE that points it at another origin: a wiremock server in tests, an institutional proxy in the field. The HTTP client has to agree with the sources about that, and it used to do so through two hand-maintained copies (the CLI’s build_http_client and the MCP server’s build_http_client_for_fetch), each with a selection condition and a registration list. The lists knew six to eleven of the fifteen overridable keys, so setting any one base put the process in test mode and silently dropped the rest from the client – datacite, hal, openaire, core and europe-pmc could not be mocked at all.

BASE_OVERRIDES is now the only list, and test_client_from_env the only builder that reads it.

§Which variables switch to the test client

Only the rows marked BaseOverride::selects_test_client – the same seven the condition always tested. The others are honoured within test mode but never cause it, and that asymmetry is deliberate: the production client is https_only and applies its allowlists to redirects, so DOIGET_APS_BASE=https://proxy.example.edu alone works today on the production client, with every other source intact. Making it select the test client would rebuild the process from the overrides alone and drop Crossref, which is the regression the issue’s option 2 would have shipped.

Test mode stays exclusive: a source with no override is absent from the test client, so a test that forgot to mock one fails immediately and offline with UnknownSource instead of reaching the real API. That isolation is the property the issue’s first-proposed additive fix would have lost.

Structs§

BaseOverride
One overridable source.

Enums§

BaseOverrideError
Why the override environment could not become a client.

Constants§

BASE_OVERRIDES
Every DOIGET_*_BASE a fetch source reads. Rows sharing a source are alternatives, the first one set winning: DOIGET_ARXIV_SRC_BASE is the source-bundle endpoint’s override and stands in for DOIGET_ARXIV_BASE only when that is unset.

Functions§

test_client_from
test_client_from_env over an arbitrary variable lookup, for tests.
test_client_from_env
The allow-http test client for the overrides set in the environment, or None when no BaseOverride::selects_test_client variable is set and the caller should build its production client.