Skip to content

fix(storage-resize-images): log errors that escape the trigger at ERROR severity - #3281

Merged
IzaakGough merged 3 commits into
kitsfrom
fix/kits-resize-images-log-handler-errors
Oct 27, 2026
Merged

IzaakGough merged 3 commits into
kitsfrom
fix/kits-resize-images-log-handler-errors

Conversation

@IzaakGough

@IzaakGough IzaakGough commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3267.

When the kit failed before resizing, for example with an invalid SHARP_OPTIONS, the error appeared in Cloud Logging with no severity, so error alerts never fired.

This logs any such error at ERROR severity before failing, and the README now recommends alerting on logs.

  • Timeouts and out-of-memory kills are not covered. The function is stopped before it can log an error, so the README names the Cloud Run messages to alert on instead.

Tested with unit tests and a live deploy, where an invalid SHARP_OPTIONS logged at ERROR. Timeouts and out-of-memory kills were not tested.

…OR severity

An error thrown before the resize, such as an invalid SHARP_OPTIONS, reached the logs only as unstructured stderr. Log it with logger.error and rethrow, and note in the README that 2nd gen failures should be alerted on from logs.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request improves error handling and logging for the 2nd generation generateResizedImage Cloud Function to ensure unhandled errors are logged at ERROR severity, allowing for reliable log-based alerting. It updates the README with alerting guidelines, adds an unhandledError logger helper, and introduces corresponding unit tests. Feedback suggests importing logger from "firebase-functions" instead of "firebase-functions/v2" in the test file to maintain consistency with the main codebase.

Comment thread kits/storage-resize-images/tests/unhandled-error.test.ts Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@IzaakGough
IzaakGough marked this pull request as ready for review October 26, 2026 15:00
Comment thread kits/storage-resize-images/src/logs.ts Outdated
Comment thread kits/storage-resize-images/README.md Outdated
Comment thread kits/storage-resize-images/README.md Outdated
Comment thread kits/storage-resize-images/tests/unhandled-error.test.ts Outdated
Matches the extension's ERROR entry so Error Reporting groups each failure once. The README now says that failed events are always recorded as HTTP 200 and that timeouts are never logged at ERROR.
@IzaakGough
IzaakGough merged commit 06daccd into kits Oct 27, 2026
11 checks passed
@IzaakGough
IzaakGough deleted the fix/kits-resize-images-log-handler-errors branch October 27, 2026 15:56
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