Skip to content

Commit

Permalink
fix: add opt-out for appId mismatch check during init (#14013)
Browse files Browse the repository at this point in the history
* chore: add opt-out for appId mismatch during init via environment variable

* chore: update messaging
  • Loading branch information
awsluja authored Nov 13, 2024
1 parent b40e8e8 commit 87a6b4c
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/amplify-cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ export const run = async (context: $TSContext): Promise<void> => {
constructExeInfo(context);
checkForNestedProject();

const projectPath = process.cwd();
if (stateManager.metaFileExists(projectPath)) {
const inputAppId = context.exeInfo?.inputParams?.amplify?.appId;
const appId = getAmplifyAppId();
if (inputAppId && appId && inputAppId !== appId) {
throw new AmplifyError('InvalidAmplifyAppIdError', {
message: `Amplify appId mismatch.`,
resolution: `You are currently working in the amplify project with Id ${appId}`,
});
// Opt-out mechanism for customers that are using old app backend environments with existing apps intentionally
const { AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK } = process.env;
if (AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK !== 'true') {
// check for appId mismatch
const projectPath = process.cwd();
if (stateManager.metaFileExists(projectPath)) {
const inputAppId = context.exeInfo?.inputParams?.amplify?.appId;
const appId = getAmplifyAppId();
if (inputAppId && appId && inputAppId !== appId) {
throw new AmplifyError('InvalidAmplifyAppIdError', {
message: `Amplify appId mismatch.`,
resolution: `You are currently working in the amplify project with Id ${appId}. If this is intentional, you may bypass this protection by setting the environment variable AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK to true.`,
});
}
}
}

Expand Down

0 comments on commit 87a6b4c

Please sign in to comment.