Skip to content

feat: per-backend API path, e.g., for TESP - #417

Merged
uniqueg merged 4 commits into
devfrom
fix/backend-api-path
Nov 4, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/backend-api-path

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Closes #411

Summary

TESP serves its API below /v1, and proTES sent all requests to the path of the TES specification. Entries of custom.tes.backends can now set api_path (default /ga4gh/tes/v1), apiPath in the chart.

  • TesClient uses it for tasks, cancellation and service info; check_outbound keeps working on the canonical path, so plugins don't have to know it.
  • The option lives in proTES: TesServiceEntry extends FOCA's ServiceEntry, and Tes.parse_tes_instances parses entries before FOCA's list model, which keeps subclass instances. No FOCA change is needed.
  • Discovered backends use the default path, unless the same URL is also configured as an entry (listed on chore: smaller findings of the 0.5.0 review #416).
  • Docs: docs/configuration.md ("API paths", naming TESP), chart README and values.
  • Smoke test: a fake that serves only /v1, with a task held and canceled.

Verification

  • python -m pytest with real Helm: 1517 passed, 11 skipped. pre-commit run --from-ref origin/dev --to-ref HEAD: passed.
  • Compose smoke test and docs build: run in CI only (no local Docker in the sandbox).
  • Not verified against a real TESP; the path comes from reading its source in the pre-release review.

Declined review findings

  • A plain ServiceEntry instance defaults to the default path: only programmatic use and tests, covered by test_api_path_default.
  • Dependence on FOCA's list keeping subclasses, or a hook in FOCA instead: test_api_path_candidates and the smoke config test catch a loss; a hook would be a FOCA change, and none is planned for 0.5.0.
  • Prefix logic in forward: non-default paths are covered by test_forward_outbound.
  • FAKE_TES_BASE_PATH also disables tokens in the fake: test helper only.
  • Duplicated test setup: minor.
  • Chart schema vs. app on dot segments and repeated trailing slashes: the app's check is the backstop and fails loudly at start.
  • model_dump drops api_path: no dump and reload exists; documented in the docstring.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Allow each configured TES backend to use a custom API path while preserving the canonical proTES API path for plugins and defaulting discovered backends to the standard path.

New Features:

  • Support configuring a per-backend TES API path, including /v1 for TESP, while retaining the standard path by default.

Enhancements:

  • Apply configured API paths consistently to task forwarding, retrieval, cancellation, and service-info requests while keeping the canonical path visible to plugins.
  • Validate and preserve TES-specific backend settings separately from service-registry discovery, with discovered backends continuing to use the default API path.

Deployment:

  • Expose the backend API path as apiPath in the Helm chart and validate it in chart values.

Documentation:

  • Document custom TES API paths, TESP configuration, path constraints, and behavior for discovered backends.

Tests:

  • Add unit, chart, configuration, and smoke coverage for custom API paths, root paths, defaults, invalid values, and task cancellation.

uniqueg and others added 3 commits November 4, 2026 06:25
Add `api_path` to the entries of TES instances in `custom.tes.backends`
(`apiPath` in the chart; default `/ga4gh/tes/v1`), for TES instances
that serve the API elsewhere, as TESP does at `/v1`. FOCA's models keep
entries of a subclass as they are, so it lives in proTES. Plugins and
`check_outbound` keep seeing the path of the API of proTES; the client
applies the API path when it sends a request. Add a smoke case with a
fake backend that serves `/v1` only, and name TESP in the docs.

Closes #411

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the same characters as the app's check, and rewrap the docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v0.5.0 milestone Nov 4, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR adds validated per-backend TES API paths, preserving canonical /ga4gh/tes/v1 paths for plugins while translating requests at the backend client; it exposes the setting through Helm and documents TESP support, with unit, chart, configuration, and end-to-end smoke-test coverage.

Sequence diagram for per-backend TES API path translation

sequenceDiagram
    participant Plugin
    participant Gateway
    participant TesClient
    participant TESBackend

    Plugin->>Gateway: POST /ga4gh/tes/v1/tasks
    Gateway->>Gateway: check_outbound(outbound)
    Gateway->>TesClient: forward(outbound, task)
    TesClient->>TesClient: Translate DEFAULT_API_PATH to api_path
    TesClient->>TESBackend: POST /v1/tasks
    TESBackend-->>TesClient: Task response
    TesClient-->>Gateway: BackendResponse
    Gateway-->>Plugin: Forwarded task result
Loading

Sequence diagram for backend-specific task lifecycle paths

sequenceDiagram
    participant Caller
    participant TesClient
    participant TESBackend

    Caller->>TesClient: get_task(task_id)
    TesClient->>TESBackend: GET /v1/tasks/{task_id}
    TESBackend-->>TesClient: Task
    Caller->>TesClient: cancel_task(task_id)
    TesClient->>TESBackend: POST /v1/tasks/{task_id}:cancel
    TESBackend-->>TesClient: Cancellation response
    Caller->>TesClient: service_info()
    TesClient->>TESBackend: GET /v1/service-info
    TESBackend-->>TesClient: Service info
Loading

File-Level Changes

Change Details Files
Add per-backend TES API path configuration with validation and preservation of typed entries through FOCA parsing.
  • Introduce TesServiceEntry.api_path with the canonical path as the default.
  • Normalize trailing slashes, support / for root-hosted APIs, and reject unsafe or non-absolute paths.
  • Parse configured TES entries as the proTES subclass while leaving registry entries on FOCA models.
pro_tes/config_models.py
tests/ga4gh/tes/test_backends.py
tests/test_app.py
Route backend requests through each backend's configured API path while retaining the canonical path at the plugin boundary.
  • Apply custom paths to task creation forwarding, retrieval, cancellation, and service-info requests.
  • Translate only canonical TES task paths in TesClient.forward; discovered backends continue using the default path.
  • Keep outbound validation and plugin-visible paths fixed at /ga4gh/tes/v1/tasks.
pro_tes/ga4gh/tes/backends.py
pro_tes/gateway.py
Expose and document custom API paths in Helm configuration and application documentation.
  • Map chart apiPath values to application api_path configuration and validate representative invalid values in the chart schema/tests.
  • Document TESP /v1 setup, root paths, validation rules, and behavior for discovered backends and URL collisions.
  • Add chart README and default-values examples.
deployment/README.md
deployment/templates/_helpers.tpl
deployment/values.schema.json
deployment/values.yaml
docs/configuration.md
tests/test_chart.py
Add end-to-end coverage for a backend serving TES exclusively below /v1.
  • Configure a /v1-only fake TES service and wire it into the smoke-test composition.
  • Verify task creation, tracking, and cancellation through the custom path.
  • Allow the fake service to select its base path and bypass authentication for this test-only mode.
tests/smoke/check.sh
tests/smoke/compose.yaml
tests/smoke/config.yaml
tests/smoke/fake_tes.py

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 4, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35633663 | 📁 Comparing 3550141 against latest (f88399b)

  🔍 Preview build  

3 files changed
± configuration/index.html
± deployment/index.html
± reference/index.html

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f88399b) to head (3550141).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #417   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         2518      2542   +24     
=========================================
+ Hits          2518      2542   +24     

☔ 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 4, 2026 05:35

@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="642-644" />
<code_context>
         super().__init__(url=url, timeout=timeout)
         self.backend = backend
         self.entry = entry
+        self.api_path = (
+            entry.api_path if isinstance(entry, TesServiceEntry) else DEFAULT_API_PATH
+        )
         # discovered backends: each connection is checked
         self.guarded: GuardedClient | None = None
</code_context>
<issue_to_address>
**Active tasks become unreachable**

When the configured `api_path` changes while tasks created with the previous path are still active, `_poll` and `cancel_task` rebuild clients using the current backend entry's path, but task records retain only the host and task ID. Requests therefore use the wrong route, leaving those tasks untracked or uncancelable.

Store the API path used when each task is created and use it when polling or canceling that task.
</issue_to_address>

### Comment 2
<location path="pro_tes/config_models.py" line_range="322-330" />
<code_context>
+        """
+        if not value.startswith("/"):
+            raise ValueError(f"API path must be absolute: {value!r}")
+        path = value.rstrip("/")
+        if path and (
+            not _API_PATH.fullmatch(path) or {".", ".."} & set(path.split("/"))
+        ):
+            raise ValueError(
+                f"API path must have unreserved characters only, and no segments"
+                f" `.` or `..`: {value!r}"
+            )
+        return path
+
+
</code_context>
<issue_to_address>
**Repeated slashes select the root**

When `api_path` contains only multiple slashes, `rstrip("/")` turns `//` or `///` into an empty path, which passes the root-path check. `TesClient` then sends requests to the backend URL root instead of rejecting the malformed setting, so requests can fail or reach the wrong endpoint.

Accept the empty normalized path only when the original value is exactly `/`; reject other slash-only values.
</issue_to_address>

Linked issues

#411 feat: per-backend API path, e.g., for TESP · 4 of 4 met

# Requirement Status Notes
1 Add a per-entry api_path option (default /ga4gh/tes/v1, apiPath in the chart) and use it for task creation, retrieval, cancellation, and service-info requests. ✅ Met The TES entry model defaults and validates api_path; the Helm template maps apiPath, and TesClient applies the configured path to all four request types.
2 Keep plugins and check_outbound on proTES’s canonical /ga4gh/tes/v1/tasks path. ✅ Met TASKS_PATH remains based on DEFAULT_API_PATH; TesClient.forward translates that path only when sending to a backend.
3 Add a smoke case with a fake backend that serves /v1 only. ✅ Met The smoke configuration targets a fake serving /v1 and checks task creation, tracking, and cancellation.
4 Add documentation naming TESP. ✅ Met The configuration documentation names TESP and describes its /v1 API path; the deployment README also includes a TESP-style example.

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and if the configured API path is wrong but still accepts task submissions, a backend could create tasks at an unintended endpoint; those remote tasks are not removed by reverting this change, though they can generally be canceled. With the default path unchanged, the main risk is limited to backends explicitly configured with an alternate path.

Blocking findings: pro_tes/ga4gh/tes/backends.py:644, pro_tes/config_models.py:330


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/config_models.py Resolved
Only one trailing slash is removed, so that `//` isn't taken for the
root path, as in the chart's schema.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit ea0ec59 into dev Nov 4, 2026
30 checks passed
@uniqueg
uniqueg deleted the fix/backend-api-path branch November 4, 2026 05:49
uniqueg added a commit that referenced this pull request Nov 4, 2026
Brings in the review fixes #410, #412, #417, #419, #420, #421.

The only conflict is in the module docstring of
`pro_tes/ga4gh/tes/backends.py`: keeps this branch's removal of the
FOCA 0.19 caveat about redirects, and the sentence of #419 about tasks
in the view `FULL`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

feat: per-backend API path, e.g., for TESP

1 participant