Skip to content

Commit 3392aad

Browse files
committed
refactor(cli-internal): remove defensive try/catch in
extractAuthTriggerCfnPermissions If the function is category 'auth', a Cognito resource must exist. The try/catch on singleResourceName was hiding a genuine invariant violation. Let it throw naturally if something is broken. --- Prompt: Remove overly defensive try/catch from extractAuthTriggerCfnPermissions per coding guidelines.
1 parent 6aaa53e commit 3392aad

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

packages/amplify-cli/src/commands/gen2-migration/generate/amplify/function/function.generator.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,7 @@ export class FunctionGenerator implements Planner {
604604
private extractAuthTriggerCfnPermissions(): AuthPermissions {
605605
if (this.category !== 'auth') return {};
606606

607-
let authResourceName: string;
608-
try {
609-
authResourceName = this.gen1App.singleResourceName('auth', 'Cognito');
610-
} catch {
611-
// No Cognito resource found — nothing to extract.
612-
return {};
613-
}
614-
607+
const authResourceName = this.gen1App.singleResourceName('auth', 'Cognito');
615608
const templatePath = `auth/${authResourceName}/build/auth-trigger-cloudformation-template.json`;
616609
if (!this.gen1App.fileExists(templatePath)) return {};
617610

0 commit comments

Comments
 (0)