Skip to content

Sandbox identifier falls back to default after file changes #2874

Open
@alexlau811

Description

@alexlau811

Description

When running ampx sandbox with the --identifier flag, the custom identifier is displayed correctly during initial deployment. However, after the file watcher detects changes and triggers a rebuild, the identifier falls back to the default value (whoami username) in the console output.

Steps to Reproduce

  1. Run sandbox with a custom identifier:

    ampx sandbox --identifier my-custom-id
  2. Observe that the initial deployment correctly shows:

    [Sandbox] Identifier: my-custom-id
    
  3. Make any change to a watched file (e.g., modify a backend file)

  4. Observe that after the file change is detected, the console output reverts to showing the default identifier:

    [Sandbox] Identifier: <your-username>
    

Expected Behavior

The custom identifier provided via the --identifier flag should persist throughout the entire sandbox session, including after file changes trigger rebuilds.

Actual Behavior

The identifier falls back to the default (whoami) value after file changes are detected.

Root Cause

In /packages/sandbox/src/file_watching_sandbox.ts, when the file watcher detects changes, it calls printSandboxNameInfo() without passing the sandboxIdentifier parameter (line 224). This causes the method to use the default identifier instead of the custom one provided by the user.

Environment

  • amplify-backend version: latest
  • Operating System: All
  • Node.js version: All supported versions

Additional Context

This issue affects developer experience as it can cause confusion about which sandbox environment is being used, especially when working with multiple sandboxes using different identifiers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions