Skip to content

Raise error when CleanupSubDirectoryJob targets a non–pair-tree directory#853

Merged
aprilrieger merged 1 commit intomainfrom
i842-throw-error-uploads-cleanup
Mar 26, 2026
Merged

Raise error when CleanupSubDirectoryJob targets a non–pair-tree directory#853
aprilrieger merged 1 commit intomainfrom
i842-throw-error-uploads-cleanup

Conversation

@aprilrieger
Copy link
Copy Markdown
Member

@aprilrieger aprilrieger commented Mar 26, 2026

ref #842

The CleanupSubDirectoryJob should raise an error if passed one of these directories (e.g. tenant UUID roots under uploads, or any top-level dir that is not a two-character hex pair-tree segment).

What this PR does
At the start of perform, we call assert_hex_pair_tree_directory!(directory) before any glob/delete work.

The allowed shape matches CleanupUploadFilesJob::HEX_TOP_DIR_PATTERN: the basename of the directory must be exactly two hex characters (00–ff). Anything else (tenant UUID, hyrax, uploaded_collection_thumbnails, etc.) raises ArgumentError with a message that explains the allowed pattern and shows what was passed.

discard_on ArgumentError is configured so mis-queued jobs don’t burn retries under a broad StandardError retry policy; the error is logged and the job is discarded after the failure is visible.

@aprilrieger aprilrieger requested a review from maxkadel March 26, 2026 21:57
Copy link
Copy Markdown
Member

@maxkadel maxkadel left a comment

Choose a reason for hiding this comment

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

Thanks April, looks good!

@aprilrieger aprilrieger merged commit e013528 into main Mar 26, 2026
7 checks passed
@aprilrieger aprilrieger deleted the i842-throw-error-uploads-cleanup branch March 26, 2026 22:17
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.

2 participants