Skip to content

feat!: stop serving forwarded_to - #374

Merged
uniqueg merged 5 commits into
devfrom
feat/324-remove-forwarded-to
Nov 1, 2026
Merged

uniqueg merged 5 commits into
devfrom
feat/324-remove-forwarded-to

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Removes the non-TES-compliant logs[].metadata.forwarded_to (tesForward) in 0.4.0, without a deprecation period (maintainer decision, 2026-11-02). It is replaced by the gateway tags gateway.backend, gateway.backend_task_id and gateway.forwarded_at (#322).

  • New tasks no longer record forwards in their logs. TesForward, Metadata and flatten_forwards() are removed, and tesForward is gone from api/additions.openapi.yaml. TesTaskLog.metadata is now a string map that drops values that aren't strings.
  • Tasks stored by earlier versions are served (views BASIC and FULL) without forwarded_to or the 0.2 backend references remote_task_id and tes_uri, using an exclusion projection. They can still be canceled: tes_endpoint.task_id is used first, then the stored forwards (as a list or as a nested object), then remote_task_id. Malformed forwards return 409; before, they failed validation with a 500.
  • custom.storeLogs is removed. The app refuses to start and the Helm chart refuses to render with it.
  • Docs: the upgrading guide has a new checklist item and a "Forwards in task logs" section (with the field-to-tag mapping), and its 0.3.0 notes are aligned. docs/api.md and docs/configuration.md are updated too.

Unfinished tasks stored before 0.3.0 can be canceled but aren't tracked again. Tracking needs tes_endpoint.task_id. This hasn't changed since 0.3.0 and is now stated consistently in the docs.

Closes #324

Verification

  • pytest: 1105 passed, 177 skipped. Coverage is 100% (coverage run -m pytest and coverage report).
  • ruff format, ruff check and mypy (70 files) report no issues.
  • mkdocs build --strict: OK.
  • ast-grep scan: clean. Semgrep runs in the push hook.
  • New or changed tests cover:
    • stored legacy forwards (list and nested) in BASIC and FULL, served without backend references and canceled at the last forward;
    • invalid forwards (409) and legacy cancel through remote_task_id;
    • tracking of legacy tasks;
    • the refusal of custom.storeLogs in the config and in the chart;
    • the absence of forwarded_to from the spec;
    • the smoke check (forwarded_to == null against real MongoDB in CI).
  • CI: all checks pass (CI passed, tests on MongoDB 7.0 and mongomock, smoke test, chart, docs, lint, image scan, CodeQL, Codecov).
  • After the Sourcery fixes (b777f35): 1107 passed, 177 skipped, 100% coverage, and CI passed.
  • Review: two rounds of adversarial and quality reviewer subagents. All high and medium findings and the cheap low findings are fixed.

Declined review findings

  • Sourcery, "Track legacy unfinished tasks": tracking has resumed only tasks with tes_endpoint.task_id since 0.3.0 (fix: track tasks by rescheduled polls #288), so unfinished tasks stored before 0.3.0 keep their last state. This PR doesn't change that. Every task that 0.3.x tracks is still tracked, and pre-0.3.0 tasks can still be canceled. Resuming those tasks from their log metadata would be new behaviour, outside feat!: stop serving forwarded_to #324.

Open questions

  • None.

🤖 Generated with Claude Code

Summary by Sourcery

Remove forwarded task details from task logs and use gateway tags while maintaining compatible serving, cancellation, and tracking of legacy tasks.

Bug Fixes:

  • Preserve cancellation support for tasks stored by earlier versions while preventing malformed legacy forwarding metadata from causing server errors.

Enhancements:

  • Remove non-compliant forwarded task details from logs and replace them with gateway tags.
  • Serve legacy tasks without forwarded or obsolete backend references while retaining string-only log metadata.
  • Remove the TesForward and Metadata models and forwarding log processing in favor of TES-compliant task log metadata.

Deployment:

  • Reject the removed custom.storeLogs setting during application startup and Helm chart rendering.

Documentation:

  • Document the removal of forwarded_to, its gateway-tag replacements, legacy task behavior, and required upgrade actions.

Tests:

  • Update API, server, legacy compatibility, cancellation, tracking, configuration, chart, and smoke tests for the removal of forwarded_to.

Chores:

  • Remove tesForward and forwarded_to from the API additions specification and eliminate the default storeLogs configuration.

uniqueg and others added 3 commits November 1, 2026 09:19
Remove `logs[].metadata.forwarded_to` (`tesForward`), replaced by the
gateway tags `gateway.backend` and `gateway.backend_task_id` (#322),
without a deprecation period (maintainer decision for 0.4.0).

- No longer record forwards in task logs; drop `TesForward`, `Metadata`
  and `flatten_forwards()`; `TesTaskLog.metadata` is a string map that
  drops non-string values.
- Serve tasks stored by earlier versions without `forwarded_to` (views
  `BASIC` and `FULL`), but still cancel them by their stored forwards.
- Remove `custom.storeLogs`; the app and the Helm chart refuse it.
- Document the breaking change in the upgrade guide.

BREAKING CHANGE: tasks are served without `logs[].metadata.forwarded_to`
and `custom.storeLogs` is refused; read the gateway tags instead.

Closes #324

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Serve tasks stored by earlier versions without `remote_task_id` and
`tes_uri` in their log metadata either, which the removed `Metadata`
model dropped, and test that the projection hides them. Document that
unfinished tasks stored before 0.3.0 are canceled but not tracked, and
apply the remaining review fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
State in the 0.3.0 notes, too, that unfinished tasks stored before 0.3.0
are canceled but not tracked again, and reword a projection comment.

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

sourcery-ai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This breaking change stops recording and serving non-TES-compliant forwarded_to log metadata, uses gateway tags for forwarding information, and maintains controlled cancellation and tracking compatibility for legacy stored tasks while rejecting the removed storeLogs configuration.

Sequence diagram for legacy task cancellation

sequenceDiagram
    participant Client
    participant TaskRuns
    participant Database
    participant Backend

    Client->>TaskRuns: cancel_task(id)
    TaskRuns->>Database: load stored task
    TaskRuns->>TaskRuns: _remote_task_id(document)
    alt tes_endpoint.task_id exists
        TaskRuns->>Backend: cancel_task(tes_endpoint.task_id)
    else legacy forwarded_to exists
        TaskRuns->>Backend: cancel_task(last forward id)
    else remote_task_id exists
        TaskRuns->>Backend: cancel_task(remote_task_id)
    else malformed forward
        TaskRuns-->>Client: 409 Conflict
    end
Loading

File-Level Changes

Change Details Files
Remove forwarded task-log metadata and replace it with gateway tags for new tasks.
  • Deleted the TesForward and Metadata models plus forward-flattening and log-update logic.
  • Changed log metadata to a string-only map that filters non-string values.
  • Removed the tesForward and forwarded_to API schema extensions.
  • Updated task creation, serving, smoke coverage, and documentation to use gateway.backend, gateway.backend_task_id, and gateway.forwarded_at.
pro_tes/ga4gh/tes/models.py
pro_tes/ga4gh/tes/task_runs.py
pro_tes/api/additions.openapi.yaml
pro_tes/config.yaml
docs/api.md
docs/configuration.md
docs/upgrading.md
tests/ga4gh/tes/test_models.py
tests/ga4gh/tes/test_server.py
tests/smoke/check.sh
Preserve compatibility for legacy stored tasks while hiding obsolete backend references from API responses.
  • Added BASIC and FULL MongoDB projections excluding forwarded_to, remote_task_id, and tes_uri.
  • Added cancellation fallback through tes_endpoint.task_id, list or nested legacy forwards, and remote_task_id.
  • Return 409 for malformed legacy forwarding data and continue tracking eligible pre-0.4.0 tasks.
  • Strip legacy forwards from persisted logs after task completion.
pro_tes/ga4gh/tes/task_runs.py
tests/ga4gh/tes/test_server.py
tests/tasks/test_track_task_progress.py
Reject the removed custom.storeLogs configuration at both application and Helm-rendering time.
  • Removed the storeLogs configuration model and default configuration.
  • Added application validation with replacement guidance.
  • Added Helm validation that fails renders containing config.custom.storeLogs.
  • Updated configuration and chart tests.
pro_tes/config_models.py
pro_tes/config.yaml
deployment/templates/_helpers.tpl
tests/test_config_examples.py
tests/test_chart.py
Align upgrade guidance and regression coverage with the breaking 0.4.0 behavior.
  • Documented the no-deprecation removal, field-to-tag mapping, legacy cancellation/tracking behavior, and removed library APIs.
  • Reworked tests for absent forwarded_to, legacy list/nested data, cancellation, tracking, config rejection, and smoke behavior.
docs/upgrading.md
docs/api.md
docs/configuration.md
tests/ga4gh/tes/test_models.py
tests/ga4gh/tes/test_provenance_api.py
tests/ga4gh/tes/test_server.py
tests/tasks/test_track_task_progress.py
tests/smoke/check.sh
tests/test_chart.py
tests/test_config_examples.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 1, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35557095 | 📁 Comparing 10e91fa against latest (6b970ac)

  🔍 Preview build  

4 files changed
± api/index.html
± configuration/index.html
± reference/index.html
± upgrading/index.html

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #374   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines         2234      2217   -17     
=========================================
- Hits          2234      2217   -17     

☔ 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 1, 2026 09:49

@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 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="pro_tes/ga4gh/tes/task_runs.py" line_range="1145-1156" />
<code_context>
-        # the metadata model drops `remote_task_id`, so it is read as stored
         stored_logs = document.get("task", {}).get("logs") or [{}]
         stored_metadata = stored_logs[0].get("metadata") or {}
+        forwards: Any = stored_metadata.get("forwarded_to")
+        # nested forwards have the next one in `forwarded_to`
+        while isinstance(forwards, dict) and isinstance(
+            forwards.get("forwarded_to"), dict
+        ):
+            forwards = forwards["forwarded_to"]
+        if isinstance(forwards, dict):
+            forwards = [forwards]
+        if isinstance(forwards, list) and forwards:
+            forward = forwards[-1]
+            if isinstance(forward, dict) and isinstance(forward.get("id"), str):
+                return forward["id"]
         remote_task_id = stored_metadata.get("remote_task_id")
         return remote_task_id if isinstance(remote_task_id, str) else None
</code_context>
<issue_to_address>
**Cancellation targets the wrong task**

When stored forwards are malformed and either a stale `remote_task_id` or a valid outer ID is available, `_remote_task_id` falls back to `remote_task_id` or accepts the outer forward ID, so `cancel_task` sends a stale or upstream identifier to the backend instead of returning 409.

Validate the entire forwards chain and return no remote ID whenever any present link is malformed, so `cancel_task` rejects it with 409.
</issue_to_address>

### Comment 2
<location path="pro_tes/ga4gh/tes/task_runs.py" line_range="698-701" />
<code_context>
                 )
             else:
-                tasks.append(flatten_forwards(document["task"]))
+                tasks.append(document["task"])
         cursor.close()
         logger.debug("Listed %s tasks", len(tasks))
</code_context>
<issue_to_address>
**Legacy metadata bypasses filtering**

When a stored task contains a non-string log metadata value outside the excluded fields, `list_tasks` and `get_task` return raw task dictionaries, so `TesTaskLog.drop_non_string_metadata` does not run and responses violate the TES string-map contract.

Parse or filter tasks before returning them from `list_tasks` and `get_task` so their log metadata contains only strings.

Also at `pro_tes/ga4gh/tes/models.py:419-421`.
</issue_to_address>

### Comment 3
<location path="tests/tasks/test_track_task_progress.py" line_range="298" />
<code_context>
+        {"$set": {"task.logs.0.metadata": {"forwarded_to": forwards, "a": "b"}}},
+    )
+    run()
+    document = tasks.find_one({"worker_id": ARGS["worker_id"]})
+    assert document is not None
+    assert document["task"]["state"] == "COMPLETE"
</code_context>
<issue_to_address>
**Wrong backend task ID passes**

When the tracking code sends an incorrect `remote_task_id`, `test_stored_forwards_tracked` only checks the resulting state and metadata at lines 300–302; `FakeClient.get_task` returns `COMPLETE` for any ID, so tracking the wrong backend task still passes.

Assert that `client_class.requested` contains the expected ID in this test, or make the fake reject unexpected IDs.
</issue_to_address>

Linked issues

#324 feat!: stop serving forwarded_to · 3 of 5 met

# Requirement Status Notes
1 Stop writing and serving metadata.forwarded_to; remove tesForward, TesForward and flatten_forwards(). ✅ Met New forwards are no longer written, the schema and models are removed, and legacy log metadata is filtered from task responses.
2 Keep old task forwards and remote_task_id available internally for tracking and cancellation; use tes_endpoint.task_id for new tasks. 🟡 Partly met Legacy forwards and remote_task_id are used for cancellation, and new tasks use tes_endpoint.task_id; however, resuming tracking requires that endpoint field, so old unfinished tasks without it are not tracked.
3 Remove custom.storeLogs. ✅ Met The app rejects the setting and the Helm chart refuses to render with it.
4 Document the breaking change and point users to the gateway.* tags. ✅ Met The upgrading guide describes the removal and maps the former log fields to gateway tags.
5 Ensure old unfinished tasks remain tracked and cancelable, and no served task has metadata.forwarded_to. 🟡 Partly met Legacy forwards are hidden and old tasks can be canceled, but unfinished tasks without tes_endpoint.task_id are not resumed for tracking.

Sourcery assessment

Needs a human reviewer. 3 findings to address first, and tasks created while this version is running will no longer record the forwarding history in their logs; the gateway tags retain the backend and remote task ID, but not necessarily every hop. Reverting restores the old behavior for future tasks, but cannot reconstruct forwarding details that were never recorded.

Blocking findings: pro_tes/ga4gh/tes/task_runs.py:1156, pro_tes/ga4gh/tes/task_runs.py:701, tests/tasks/test_track_task_progress.py:298


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

Comment thread pro_tes/ga4gh/tes/task_runs.py Resolved
Comment thread pro_tes/ga4gh/tes/task_runs.py Resolved
Comment thread tests/tasks/test_track_task_progress.py Resolved
Drop log metadata of stored tasks that is not strings when serving
them, and refuse to cancel tasks with malformed stored forwards at any
level (409) instead of falling back to an outer or replaced remote
identifier. Check that legacy tasks are tracked by their remote
identifier (Sourcery review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

Linked issues

#324 feat!: stop serving forwarded_to · 3 of 4 met

# Requirement Status Notes
1 Stop writing and serving metadata.forwarded_to; remove tesForward, TesForward and flatten_forwards(). ✅ Met New logs no longer record forwards, old non-string metadata is filtered when serving, and the schema, models and helper are removed.
2 Keep reading stored forwards and remote_task_id internally for tracking and cancellation; new tasks use tes_endpoint.task_id. 🟡 Partly met Cancellation resolves legacy identifiers from stored forwards or remote_task_id, but tracking resumes only tasks with tes_endpoint.task_id, leaving older forward-only unfinished tasks untracked.
3 Remove custom.storeLogs and refuse it in the app and Helm chart. ✅ Met The app rejects the removed key and the chart validation fails when it is configured.
4 Document the breaking change and point clients to the gateway.* tags. ✅ Met The upgrade guide and API documentation describe the removal and the replacement tags.

Comment thread tests/tasks/test_track_task_progress.py Resolved
@uniqueg
uniqueg merged commit e91ca60 into dev Nov 1, 2026
32 checks passed
@uniqueg
uniqueg deleted the feat/324-remove-forwarded-to branch November 1, 2026 10:30
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!: stop serving forwarded_to

1 participant