Skip to content

feat(worker): set MERGED state on successful uploads after merge#746

Open
thomasrockhu-codecov wants to merge 1 commit intotomhu/finisher-passes-db-sessionfrom
tomhu/merging-sets-merged-state
Open

feat(worker): set MERGED state on successful uploads after merge#746
thomasrockhu-codecov wants to merge 1 commit intotomhu/finisher-passes-db-sessionfrom
tomhu/merging-sets-merged-state

Conversation

@thomasrockhu-codecov
Copy link
Contributor

@thomasrockhu-codecov thomasrockhu-codecov commented Mar 10, 2026

Summary

  • Changes update_uploads() in merging.py to write state_id=MERGED (6), state="merged" for successful uploads instead of state_id=PROCESSED (2), state="processed".
  • This completes the semantic distinction: PROCESSED now means "processor done, waiting for merge" while MERGED means "incorporated into the master report."
  • Adds test_merging.py with tests verifying successful uploads get MERGED state and failed uploads get ERROR state.

Stacked on #745. Safe because the finisher's idempotency check already recognizes "merged" state.

Test plan

  • CI passes
  • test_successful_uploads_set_to_merged verifies MERGED state
  • test_failed_uploads_set_to_error verifies ERROR state unchanged

Made with Cursor


Note

Medium Risk
Changes the persisted final state for successful uploads from PROCESSED to MERGED, which can affect downstream logic that keys off upload state during finishing/notification flows. Scope is small and covered by new/updated tests, but it touches core processing state transitions.

Overview
Successful uploads updated via update_uploads() are now persisted as MERGED (state_id/state) instead of PROCESSED, aligning the DB state with “incorporated into the master report” semantics.

Adds a focused unit test (test_merging.py) asserting the new success state and existing error behavior, and updates the upload finisher unit test to expect merged/UploadState.MERGED after the merge step.

Written by Cursor Bugbot for commit b1fb518. This will update automatically on new commits. Configure here.

@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from 960f041 to af9c86e Compare March 10, 2026 14:12
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/finisher-passes-db-session branch 2 times, most recently from debeee6 to 90240f9 Compare March 10, 2026 14:19
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from af9c86e to 270a3e2 Compare March 10, 2026 14:19
@thomasrockhu-codecov thomasrockhu-codecov marked this pull request as ready for review March 10, 2026 14:23
Comment on lines +132 to 135
"state_id": UploadState.MERGED.db_id,
"state": "merged",
}
report = reports.get(upload_id)
Copy link

Choose a reason for hiding this comment

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

Bug: A unit test was not updated after a change in update_uploads, causing assertions to fail by expecting state "processed" instead of the new "merged" state.
Severity: MEDIUM

Suggested Fix

Update the assertions in the test test_coverage_notifications_not_blocked_by_test_results_uploads to expect the "merged" state and the corresponding UploadState.MERGED.db_id for successful uploads, aligning the test with the new behavior of the update_uploads function.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: apps/worker/services/processing/merging.py#L132-L135

Potential issue: The function `update_uploads` was modified to set the state of
successful uploads to `"merged"` instead of `"processed"`. However, the unit test
`test_coverage_notifications_not_blocked_by_test_results_uploads` was not updated to
reflect this change. The test contains assertions that explicitly check for the old
`"processed"` state. As a result, when the test calls the real `update_uploads` function
via a mock, the assertions `assert updated_upload.state == "processed"` and `assert
updated_upload.state_id == UploadState.PROCESSED.db_id` will fail, breaking the CI
build.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed: Test assertion updated to expect state='merged' and state_id=MERGED, matching the new update_uploads behavior.

@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/finisher-passes-db-session branch from 90240f9 to f87f322 Compare March 10, 2026 14:31
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from 270a3e2 to b2ec191 Compare March 10, 2026 14:31
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/finisher-passes-db-session branch from f87f322 to 2204abd Compare March 10, 2026 14:45
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from b2ec191 to e0f5114 Compare March 10, 2026 14:45
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from e0f5114 to 7ed5926 Compare March 10, 2026 15:03
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/finisher-passes-db-session branch from 2204abd to 3b5f4ba Compare March 10, 2026 15:10
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from 7ed5926 to 948cf56 Compare March 10, 2026 15:10
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/finisher-passes-db-session branch from 3b5f4ba to 9baf0ce Compare March 10, 2026 15:21
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from 948cf56 to b40cb67 Compare March 10, 2026 15:21
@codecov-notifications
Copy link

codecov-notifications bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@sentry
Copy link

sentry bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.22%. Comparing base (b1ae759) to head (b1fb518).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                        Coverage Diff                        @@
##           tomhu/finisher-passes-db-session     #746   +/-   ##
=================================================================
  Coverage                             92.21%   92.22%           
=================================================================
  Files                                  1304     1304           
  Lines                                 47933    47933           
  Branches                               1628     1628           
=================================================================
+ Hits                                  44203    44206    +3     
+ Misses                                 3421     3418    -3     
  Partials                                309      309           
Flag Coverage Δ
workerintegration 58.62% <ø> (ø)
workerunit 90.26% <ø> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/finisher-passes-db-session branch from 9baf0ce to ae13f48 Compare March 10, 2026 15:46
@thomasrockhu-codecov thomasrockhu-codecov force-pushed the tomhu/merging-sets-merged-state branch from b40cb67 to e812cb9 Compare March 10, 2026 15:47
Change update_uploads() to write state_id=MERGED, state="merged"
for successful uploads instead of PROCESSED. This completes the
semantic distinction: PROCESSED means "processor done, waiting for
merge" while MERGED means "incorporated into the master report."

Safe because the finisher's idempotency check already recognizes
the "merged" state (done in the previous PR).

Made-with: Cursor
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.

1 participant