Skip to content

fix: read service infos without credentials - #448

Merged
uniqueg merged 4 commits into
devfrom
fix/anonymous-version-probes
Nov 6, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/anonymous-version-probes

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Version probes (GET /service-info of TES backends without the label tes.version) are now anonymous by default, as decided in #436:

  • New setting custom.tes.probe_with_token (default false). 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.
  • So backends that a task isn't routed to no longer get proTES' token, and an outage of the identity provider no longer makes backends of TES 1.1 count as 1.0.
  • Anonymous probes refused with 401/403 log a hint at the label tes.version (and at the setting, for backends with credentials).
  • TesClient.service_info() takes auth (as _send does).

Docs: configuration reference (TES versions, with the risk of the setting), access control (credentials of TES instances), base config, chart values.yaml and 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%
  • pytest against MongoDB 7.0.34 (MONGODB_TEST_URI, own mongod --nounixsocket): 1633 passed, 1 skipped
  • ruff 0.17.3 check and format, mypy, ast-grep scan and test, semgrep (.semgrep): pass
  • mkdocs build --strict: pass
  • CI: see checks of the latest commit

Review

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: .netrc credentials could reach backends of anonymous probes. Out of scope: requests applies .netrc to 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

uniqueg and others added 2 commits November 6, 2026 16:14
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

TES 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 probing

sequenceDiagram
    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
Loading

Sequence diagram for credentialed TES version probing

sequenceDiagram
    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)
Loading

File-Level Changes

Change Details Files
Make TES service-info version probes anonymous by default, with an opt-in mode for backend credentials.
  • Add custom.tes.probe_with_token, defaulting to false, to configuration models and deployment examples.
  • Pass explicit authentication selection through TesClient.service_info() and use anonymous or backend credentials during version probes.
  • Preserve prior version-cache behavior while adding targeted hints for anonymous 401/403 responses, including the label and credentialed-probe setting where applicable.
  • Add coverage for anonymous requests, token and Basic credential suppression/inclusion, refusal hints, and non-hinting failures.
  • Document probe timing, security implications, configuration, access control, chart usage, and upgrade behavior.
pro_tes/config.yaml
pro_tes/config_models.py
pro_tes/ga4gh/tes/backends.py
tests/ga4gh/tes/conftest.py
tests/ga4gh/tes/test_backend_versions.py
tests/ga4gh/tes/test_server.py
deployment/README.md
deployment/values.yaml
docs/access-control.md
docs/configuration.md
docs/upgrading.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35702691 | 📁 Comparing 10514a0 against latest (d237a18)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d237a18) to head (10514a0).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 6, 2026 16:01

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread pro_tes/ga4gh/tes/backends.py Resolved
Comment thread pro_tes/ga4gh/tes/backends.py Resolved
uniqueg and others added 2 commits November 6, 2026 17:17
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]>
@uniqueg
uniqueg merged commit a9bc104 into dev Nov 6, 2026
43 of 50 checks passed
@uniqueg
uniqueg deleted the fix/anonymous-version-probes branch November 6, 2026 16:36
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.

fix: version probes without proTES's token

1 participant