Skip to content

fix(plugins): key failure records by run ID - #587

Merged
uniqueg merged 2 commits into
devfrom
fix/575-failure-record-run-id
Nov 1, 2026
Merged

uniqueg merged 2 commits into
devfrom
fix/575-failure-record-run-id

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Failure records (record_failed) are keyed by run-<server-generated run ID> instead of the client-supplied X-Request-ID; the request ID stays in the record as request_id. New migration guide for 0.20.0 (breaking change for consumers that look up failure records by _id), docs updated.

Closes #575

Verification

  • pytest (full suite, local MongoDB 7.0 on its own port): 3241 passed, 2 skipped; coverage report: 100%
  • ruff check, ruff format --check, mypy: clean
  • New tests: key is the run ID and request ID is a field; reused request IDs don't overwrite
  • Not run locally: mkdocs build --strict, ast-grep, Helm tests, integration tests (left to CI)

Review

Regular lane: adversarial reviewer found nothing; quality reviewer found 2 medium + 1 low in the migration guide, all fixed (docs only, no second round).

Declined review findings

None.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Key stored failure records by server-generated run IDs while retaining request IDs for correlation.

Bug Fixes:

  • Prevent failure records from being overwritten when clients reuse the same request ID by keying them with the server-generated run ID.

Enhancements:

  • Keep the client request ID as a searchable request_id field for failure-record correlation.

Documentation:

  • Add and publish a 0.20.0 migration guide describing the failure-record key change and compatibility considerations.
  • Update provenance plugin documentation to reflect the new failure-record identity and legacy records.

Tests:

  • Add coverage confirming failure records use run IDs and that reused request IDs produce distinct records.

uniqueg and others added 2 commits November 1, 2026 17:56
Failure records were keyed by the client-supplied X-Request-ID, so a
client could reuse an ID to overwrite an earlier record or collide with
other clients' records. Key them by the server-generated run ID and keep
the request ID as the field request_id. Document the change in the new
migration guide for 0.20.0.

Closes #575

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Link 0.18.0 as the previous guide, list the change under breaking changes and explain lookups during the transition.

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

sourcery-ai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR prevents failed-run records from colliding when clients reuse request IDs by keying them with each run’s server-generated ID, while retaining the request ID for correlation. It adds focused regression coverage and documents the breaking lookup change, including compatibility guidance for legacy records.

Sequence diagram for failure record persistence by run ID

sequenceDiagram
    participant Client
    participant PipelineRun
    participant ProvenanceStore
    participant MongoDB

    Client->>PipelineRun: request()
    PipelineRun->>ProvenanceStore: save_failure(run, error)
    ProvenanceStore->>MongoDB: replace_one(_id=run-run_id, request_id=request_id, upsert=true)
    MongoDB-->>ProvenanceStore: failure record stored
    ProvenanceStore-->>PipelineRun: true
Loading

File-Level Changes

Change Details Files
Key failed-run provenance records by the server-generated run ID while retaining the client request ID for correlation.
  • Changed failure-record _id generation to always use run-<run_id>.
  • Preserved request_id in the stored record and documented replacement/idempotency behavior.
  • Added tests for run-ID keys, request-ID retention, and isolation when request IDs are reused.
foca/plugins/provenance.py
foca/plugins/engine.py
tests/plugins/test_plugin_provenance.py
Document the 0.20.0 migration and updated failure-record lookup semantics.
  • Added migration guidance for querying new records by request_id and handling legacy 0.19 records keyed by _id.
  • Updated provenance documentation, changelog links, and MkDocs navigation.
docs/migration-0.20.md
docs/changelog.md
docs/plugins.md
mkdocs.yml

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

@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 (9055e87) to head (477bfab).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #587   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         7068      7068           
=========================================
  Hits          7068      7068           
Flag Coverage Δ
test_unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 17:06

@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 reviewed your changes and they look great!

Linked issues

#575 fix(plugins): key failure records by run ID · 4 of 4 met

# Requirement Status Notes
1 Failure records keyed by a server-generated run ID ✅ Met save_failure uses run-<run_id>; PipelineRun generates run_id with uuid.uuid4().hex.
2 Request ID kept as a field ✅ Met The request ID remains in the provenance record as request_id.
3 Tests that reused request IDs don't overwrite ✅ Met The added test saves failures from two runs with the same request ID and asserts both records remain.
4 Docs and upgrade notes ✅ Met The provenance docs and 0.20.0 migration guide describe the new keys and explain how to look up records during the transition while old records remain.

Sourcery assessment

Needs a human reviewer. Failure records are now stored under server-generated run IDs, so code that expects request IDs in _id will miss new records; they remain recoverable through request_id, and reverting would not change keys already written. The change also prevents reused client request IDs from overwriting one another’s records.


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

@uniqueg
uniqueg merged commit 9495228 into dev Nov 1, 2026
80 checks passed
@uniqueg
uniqueg deleted the fix/575-failure-record-run-id branch November 1, 2026 17:15
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(plugins): key failure records by run ID

1 participant