Skip to content

fix(lambda): handle NoSuchKey when tagging deleted object#1694

Open
Yashk-15 wants to merge 1 commit into
awslabs:mainfrom
Yashk-15:fix/1307-tagging-nosuchkey
Open

fix(lambda): handle NoSuchKey when tagging deleted object#1694
Yashk-15 wants to merge 1 commit into
awslabs:mainfrom
Yashk-15:fix/1307-tagging-nosuchkey

Conversation

@Yashk-15

@Yashk-15 Yashk-15 commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #1307

Problem

If a file is deleted from S3 mid-scan (after the scan finishes but before the Lambda tags the result), set_status() calls put_object_tagging() on an object that no longer exists. This raises an unhandled NoSuchKey ClientError, crashing the Lambda instead of failing gracefully.

Fix

Wrapped the put_object_tagging call in set_status() with the same error-handling pattern already used elsewhere in the file (see get_status) - catching NoSuchKey/404 specifically and logging it, while still surfacing other unexpected errors as warnings.

Testing

Added test_set_status_put_tagging_nosuchkey, which stubs a NoSuchKey error on put_object_tagging and confirms set_status no longer raises. Full test suite (25 tests) passes locally.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

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.

Lambda exits with uncaught exception if file was removed before check is finished

1 participant