Skip to content

chore(cli): improve gen2-migration logging and error handling#14889

Open
iliapolo wants to merge 1 commit into
devfrom
epolon/gen2-migration-debug-logging
Open

chore(cli): improve gen2-migration logging and error handling#14889
iliapolo wants to merge 1 commit into
devfrom
epolon/gen2-migration-debug-logging

Conversation

@iliapolo
Copy link
Copy Markdown
Contributor

@iliapolo iliapolo commented May 17, 2026

Description of changes

Improves the gen2-migration command's debuggability and error resilience.

Debug logging to file

In non-debug mode, SpinningLogger.debug() calls now write to a temp file at
$TMPDIR/amplify-gen2-migration/logs/gen2-migration-<timestamp>.log. When a
migration step fails, the error message includes the log file path so users can
share it for troubleshooting without needing to re-run with --debug.

The top-level run() function catches errors and appends the stacktrace to the
debug log before re-throwing, ensuring the log file always contains the full
failure context.

Rollback error isolation

The auto-rollback path now wraps implementation.rollback() in its own
try/catch. Previously, a rollback failure would replace the original error,
making it impossible to diagnose the root cause. Now both errors are surfaced.

Lock step debug statements

Added logger.debug() calls in the lock step for template fetching, retention
policy modifications, changeset creation, and changeset validation. These appear
in the log file (or terminal in --debug mode) and help trace exactly which
stack/resource was being processed when a failure occurs.

Spinner UX cleanup

  • Removed redundant prefix from planning/validation success/failure messages
  • Use / bullets in debug mode instead of generic
  • Use [INFO]/[DEBUG]/[WARN] labels in debug mode for grep-ability
  • Suppress push() output in debug mode (the hierarchical context is noisy
    without the spinner visual)

Issue #, if available

N/A

Description of how you validated changes

  • TypeScript compilation passes (tsc --noEmit)
  • Pre-commit hooks pass (prettier, eslint, commitlint)
  • Manual review of spinner output in both normal and --debug modes
  • E2Es pass.

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

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

@iliapolo iliapolo requested a review from a team as a code owner May 17, 2026 15:21
@iliapolo
Copy link
Copy Markdown
Contributor Author

Running E2E

@iliapolo iliapolo marked this pull request as draft May 17, 2026 15:36
- Write debug logs to a temp file so users can share them without
  re-running with --debug
- Surface log file path in error messages
- Wrap rollback in try/catch so a failed rollback doesn't mask the
  original error
- Add debug statements in the lock step for easier troubleshooting
- Minor spinner text cleanup (remove redundant arrows, use check/cross
  marks in debug mode)
- Log backend download progress in gen1-app
- Fix lint suppression placement in e2e package
---
Prompt: commit my changes with "chore"
@iliapolo iliapolo force-pushed the epolon/gen2-migration-debug-logging branch from 4ad459d to b98fb50 Compare May 17, 2026 15:37
@iliapolo iliapolo marked this pull request as ready for review May 18, 2026 14:34
@iliapolo iliapolo enabled auto-merge (squash) May 18, 2026 16:32
@iliapolo iliapolo disabled auto-merge May 18, 2026 17:07
@iliapolo iliapolo enabled auto-merge (squash) May 18, 2026 17:07
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.

1 participant