Skip to content
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

fix: error message when secret access key is invalid on init #13758

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,27 @@ describe('init', () => {
};
await expect(init(amplifyServiceParamsStub)).rejects.toMatchInlineSnapshot(`[ConfigurationError: Missing Region in Config]`);
});

it('throws ProjectInitError if secret access key is invalid', async () => {
const amplifyClientStub = {
createApp: jest.fn().mockReturnValue({
promise: jest.fn().mockRejectedValue({
code: 'InvalidSignatureException',
}),
}),
} as unknown as Amplify;
getConfiguredAmplifyClientMock.mockClear();
getConfiguredAmplifyClientMock.mockResolvedValue(amplifyClientStub);

const amplifyServiceParamsStub = {
context: {},
awsConfigInfo: {},
projectName: 'test-project',
envName: 'test',
stackName: 'test-stack-name',
};
await expect(init(amplifyServiceParamsStub)).rejects.toMatchInlineSnapshot(
`[ProjectInitError: The request signature we calculated does not match the signature you provided]`,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ export async function init(amplifyServiceParams) {
resolution: 'https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html',
});
}
if (e.code === 'InvalidSignatureException') {
throw new AmplifyError(
'ProjectInitError',
{
message: 'The request signature we calculated does not match the signature you provided',
resolution: 'Check your AWS Secret Access Key',
},
e,
);
}
// default fault
throw new AmplifyFault(
'ProjectInitFault',
Expand Down