Skip to content

fix: maintain custom sandbox identifier after file changes #2875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexlau811
Copy link

@alexlau811 alexlau811 commented Jun 29, 2025

Summary

This PR fixes an issue where the sandbox identifier falls back to the default value (whoami) after file changes are detected by the file watcher.

  • Ensures custom identifier provided via --identifier flag persists throughout the entire sandbox session
  • Passes the sandboxIdentifier parameter to printSandboxNameInfo() when called from the file watcher

Issue

Fixes #2874

Description of Changes

In packages/sandbox/src/file_watching_sandbox.ts, the file watcher was calling printSandboxNameInfo() without passing the sandboxIdentifier parameter. This caused the method to fall back to using the default identifier (whoami) instead of the custom one provided by the user.

The fix is simple: pass options.identifier to the method call on line 224.

Test Plan

Manual Testing

  1. Run sandbox with a custom identifier:
    ampx sandbox --identifier my-custom-id
  2. Verify that the initial deployment shows the custom identifier
  3. Make a change to any watched file
  4. Verify that after the file change is detected, the console still shows the custom identifier

Expected Behavior

  • Before fix: Identifier reverts to default (username) after file changes
  • After fix: Identifier remains as the custom value throughout the session

Verification

  • ✅ All unit tests passed (56 tests in sandbox package)
  • ✅ Linting passed (npm run lint)
  • ✅ Build successful (npm run build)
  • ✅ Added changeset for version management

Checklist

  • Unit tests passed
  • Integration tests passed
  • Manual testing completed
  • No breaking changes

🤖 Generated with Claude Code

@alexlau811 alexlau811 requested a review from a team as a code owner June 29, 2025 07:49
When running sandbox with --identifier flag, the custom identifier
now persists throughout the entire session, including after file
changes trigger rebuilds.

Previously, the identifier would fall back to default (whoami) after
file changes because printSandboxNameInfo() was called without passing
the sandboxIdentifier parameter.

Fixes aws-amplify#2874

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@alexlau811 alexlau811 force-pushed the fix-sandbox-identifier-persistence branch from 01f7a38 to 3a3fa02 Compare June 29, 2025 07:57
Copy link

changeset-bot bot commented Jun 29, 2025

🦋 Changeset detected

Latest commit: 3a3fa02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/sandbox Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@Amplifiyer Amplifiyer left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! Can you also add unit tests for this change?

@Amplifiyer
Copy link
Contributor

@alexlau811 are you able to add some unit test coverage to this PR?

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.

Sandbox identifier falls back to default after file changes
2 participants