Skip to content

Process the correct record upon record.copy events#681

Merged
liam-lloyd merged 1 commit intomainfrom
per-10488_send_correct_file_to_archivematica_upon_copy_events
Mar 17, 2026
Merged

Process the correct record upon record.copy events#681
liam-lloyd merged 1 commit intomainfrom
per-10488_send_correct_file_to_archivematica_upon_copy_events

Conversation

@liam-lloyd
Copy link
Member

Currently when a record is copied we trigger archivematica for the original record (which has already been processed by archivematica) rather than the copy. This commit fixes that.

@liam-lloyd liam-lloyd force-pushed the per-10488_send_correct_file_to_archivematica_upon_copy_events branch from 7870273 to f5bb402 Compare March 13, 2026 17:49
@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.27%. Comparing base (f67dcdb) to head (b373953).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #681   +/-   ##
=======================================
  Coverage   98.27%   98.27%           
=======================================
  Files         107      107           
  Lines        2673     2673           
  Branches      453      453           
=======================================
  Hits         2627     2627           
  Misses         42       42           
  Partials        4        4           
Flag Coverage Δ
api 98.27% <ø> (ø)

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liam-lloyd liam-lloyd force-pushed the per-10488_send_correct_file_to_archivematica_upon_copy_events branch from f5bb402 to 42e3406 Compare March 13, 2026 21:52
@liam-lloyd liam-lloyd force-pushed the per-10488_send_correct_file_to_archivematica_upon_copy_events branch from 42e3406 to 61a5a71 Compare March 16, 2026 17:08
@slifty slifty requested a review from Copilot March 17, 2026 19:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes record.copy handling in the Archivematica trigger so that processing is initiated for the copied record rather than the original, aligning behavior with the event payload structure (newRecord).

Changes:

  • Update record ID extraction to use body.newRecord.recordId for record.copy events.
  • Extend unit tests to cover missing newRecord and validate multi-record handling.
  • Expand SQL fixtures to include additional records/files needed for the updated test scenarios.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/trigger_archivematica/src/index.ts Correctly selects the copied record ID on record.copy events.
packages/trigger_archivematica/src/index.test.ts Adds/updates tests to exercise record.copy path and multi-message handling.
packages/trigger_archivematica/src/fixtures/create_test_records.sql Adds records needed for copy/deleted-file test cases.
packages/trigger_archivematica/src/fixtures/create_test_record_files.sql Updates record↔file relationships to support new test coverage.
packages/trigger_archivematica/src/fixtures/create_test_files.sql Adds an additional file fixture used by new/updated tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +40 to +49
} else if (action === "copy") {
if (parsedMessage.body.newRecord === undefined) {
logger.error(
`record.copy event missing newRecord: ${JSON.stringify(
parsedMessage.body,
)}`,
);
throw new Error("newRecord field missing in body of record.copy");
}
return parsedMessage.body.newRecord.recordId;
Copy link
Member Author

Choose a reason for hiding this comment

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

For posterity, the robot is wrong about this; these fields cannot be null

Comment on lines +30 to 31
if (action === "create") {
if (parsedMessage.body.record === undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bah. robots over here outperforming me.

Copy link
Collaborator

@slifty slifty left a comment

Choose a reason for hiding this comment

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

I am awkwardly waiting on copilot to notice anything but... this looks good to me!

I guess let's see if the robot finds anything useful before actually merging.

Currently when a record is copied we trigger archivematica for the
original record (which has already been processed by archivematica)
rather than the copy. This commit fixes that.
@liam-lloyd liam-lloyd force-pushed the per-10488_send_correct_file_to_archivematica_upon_copy_events branch from 61a5a71 to b373953 Compare March 17, 2026 19:53
@liam-lloyd liam-lloyd merged commit 5f49e1e into main Mar 17, 2026
30 checks passed
@liam-lloyd liam-lloyd deleted the per-10488_send_correct_file_to_archivematica_upon_copy_events branch March 17, 2026 19:59
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.

3 participants