Skip to content

fix: pg:backups:capture -v null guard on undefined logs - #3832

Merged
heroku-johnny merged 1 commit into
mainfrom
W-23597889
Jul 27, 2026
Merged

fix: pg:backups:capture -v null guard on undefined logs#3832
heroku-johnny merged 1 commit into
mainfrom
W-23597889

Conversation

@heroku-johnny

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a TypeError: undefined is not iterable crash in heroku pg:backups:capture -v when the Postgres API returns a permission error during verbose polling
  • backup.logs can be undefined when a permission error is returned, but displayLogs iterated it unconditionally
  • Widened the displayLogs parameter type from BackupTransfer['logs'] to BackupTransfer['logs'] | undefined and added a ?? [] null-coalescing guard so the method is safely a no-op when logs is absent

File: src/lib/pg/backups.ts:22

Fixes #1294
Ref: W-23597889

Test plan

  • Run heroku pg:backups:capture -v against an app where the Postgres add-on does not have backup permissions — confirm no TypeError is thrown and the command exits cleanly
  • Run heroku pg:backups:capture -v against an app with a healthy Postgres add-on — confirm verbose log lines are still printed as before (happy path unchanged)

🤖 Generated with Claude Code

When --verbose polling encounters a permission error the API may
return a transfer object with logs undefined, causing displayLogs
to throw TypeError: undefined is not iterable.

Widen the displayLogs parameter type to accept undefined and
default to an empty array via nullish coalescing, so the method
is a no-op instead of crashing.

Fixes: src/lib/pg/backups.ts:22

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@heroku-johnny
heroku-johnny requested a review from a team as a code owner July 27, 2026 19:14

@tlowrimore-heroku tlowrimore-heroku 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.

LGTM!

@heroku-johnny
heroku-johnny merged commit 3c8a567 into main Jul 27, 2026
19 checks passed
@heroku-johnny
heroku-johnny deleted the W-23597889 branch July 27, 2026 21:32
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.

TypeError from pg:backups:capture when api request fails while using verbose flag

2 participants