Repository navigation
fix: read service infos without credentials - #448
Conversation
Version probes (`GET /service-info` of TES backends without the label `tes.version`) no longer send proTES' token or Basic credentials, so that backends a task isn't routed to don't get the token, and an outage of the identity provider doesn't make backends of TES 1.1 count as 1.0. The new setting `custom.tes.probe_with_token` (default false) restores probes with the credentials of each backend. Refused anonymous probes (401, 403) log a hint at the label and the setting. Documented in the configuration reference, access control, the chart values and the upgrade notes. Closes #436 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Hint at `probe_with_token` only for backends with credentials; test that probes send the token only with the setting, and no Basic credentials without it; document the setting in the chart's README and correct when service infos are read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideTES backend version probes now request service info without credentials by default, preventing unnecessary token exposure and identity-provider dependence; operators can opt into credentialed probes, receive actionable hints for rejected anonymous requests, and configure the behavior through documented application and Helm settings. Sequence diagram for anonymous TES version probingsequenceDiagram
participant VersionResolver
participant TesClient
participant TESBackend
VersionResolver->>TesClient: service_info(auth="none")
TesClient->>TESBackend: GET /service-info without credentials
TESBackend-->>TesClient: Service info or 401/403
alt Service info returned
TesClient-->>VersionResolver: reported_version(service_info)
else Anonymous request refused
VersionResolver-->>VersionResolver: Log hint to set tes.version
end
Sequence diagram for credentialed TES version probingsequenceDiagram
participant VersionResolver
participant TesClient
participant TESBackend
participant IdentityProvider
VersionResolver->>TesClient: service_info(auth=None)
TesClient->>IdentityProvider: Obtain backend credentials
IdentityProvider-->>TesClient: Access token or Basic credentials
TesClient->>TESBackend: GET /service-info with backend credentials
TESBackend-->>TesClient: Service info
TesClient-->>VersionResolver: reported_version(service_info)
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #448 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 24 24
Lines 2685 2696 +11
=========================================
+ Hits 2685 2696 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1295" />
<code_context>
- service_info = client_for(backend, timeout=PROBE_TIMEOUT).service_info()
+ service_info = client_for(backend, timeout=PROBE_TIMEOUT).service_info(
+ auth=None if with_token else "none"
+ )
version = reported_version(service_info)
listed: Any = (
</code_context>
<issue_to_address>
**Ambient credentials leak to TES probes**
When the process has a `.netrc` entry matching a configured TES backend, `_request_params` omits the `auth` argument for `"none"`, so `requests.request` uses Requests’ default `.netrc` lookup and sends matching Basic credentials to the backend. The backend receives credentials even though the probe is configured as anonymous.
Make anonymous probes bypass Requests’ `.netrc` authentication while preserving any required proxy and TLS environment settings.
</issue_to_address>
### Comment 2
<location path="pro_tes/ga4gh/tes/backends.py" line_range="1291" />
<code_context>
Returns:
What the service info says, and when to read it again.
"""
+ with_token = get_custom_config(CustomConfig).tes.probe_with_token
try:
- service_info = client_for(backend, timeout=PROBE_TIMEOUT).service_info()
</code_context>
<issue_to_address>
**Version lookup escapes its fallback**
When `backend_version` needs to probe a backend outside a Flask application context, so `get_custom_config` cannot resolve the config, `get_custom_config` can raise before `_probe` enters its exception handler, so `backend_version` propagates the error instead of returning the oldest supported version as documented.
Read `probe_with_token` inside the `try` so config lookup failures follow the existing fallback path.
</issue_to_address>Linked issues
#436 fix: version probes without proTES's token · 1 of 1 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Decide and implement when probes send credentials and what happens when a probe fails for auth reasons. | ✅ Met | Probes are anonymous by default and use backend credentials when custom.tes.probe_with_token is true. A 401/403 is logged with a hint to set tes.version (and the setting when credentials are configured); failed probes keep a previously known version, or otherwise fall back to the oldest supported version, and are retried after 60 seconds. |
Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: pro_tes/ga4gh/tes/backends.py:1295, pro_tes/ga4gh/tes/backends.py:1291
Requests without credentials (`auth: none`, and anonymous probes) to configured backends no longer get credentials of a `.netrc` file, which `requests` reads for requests without `auth` (the guarded client of discovered backends ignores it already). Failures to read the config in a probe count as other failures (the oldest version). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Revert the no-op auth for requests without credentials: `requests` also applies `.netrc` credentials when it follows redirects, and to requests with proTES' token, so the change didn't hold what it said. Keeping `.netrc` out of all requests to backends is a change of its own. The config of a probe is still read inside its `try`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Version probes (
GET /service-infoof TES backends without the labeltes.version) are now anonymous by default, as decided in #436:custom.tes.probe_with_token(defaultfalse). With it off, probes send no credentials at all (no token, no Basic credentials), also to discovered backends; with it on, they send the credentials of each backend, as before.401/403log a hint at the labeltes.version(and at the setting, for backends with credentials).TesClient.service_info()takesauth(as_senddoes).Docs: configuration reference (TES versions, with the risk of the setting), access control (credentials of TES instances), base config, chart
values.yamland README, upgrade notes (To version 0.6.0).Closes #436
Verification
coverage run -m pytest(mongomock, Helm 3.22.1 for the chart tests): 1623 passed, 11 skipped, coverage 100%MONGODB_TEST_URI, ownmongod --nounixsocket): 1633 passed, 1 skipped.semgrep): passmkdocs build --strict: passReview
Full review (adversarial + quality, 2 rounds). Fixed: chart README mention, end-to-end tests of token and Basic credentials, hint only for backends with credentials, doc accuracy on when probes run; Sourcery: the config of a probe is read inside its
try(test_probe_without_config).Declined review findings
Sourcery:
.netrccredentials could reach backends of anonymous probes. Out of scope:requestsapplies.netrcto all requests to configured backends (also with the token, and on redirects), so anonymous probes are no special case; a fix needs a session of its own for configured backends (a first attempt that covered only the first request was reverted). Follow-up issue to be proposed.Deduplicate the risk explanation across
config.yaml,values.yaml, access control and upgrade notes: each place states what the reader there needs, with a pointer to the configuration reference, as the repo does for other settings.🤖 Generated with Claude Code