Skip to content

fix(amplify-graphql-api-construct-tests): fail fast if cdk.json tsc-strip pattern stops matching - #3520

Merged
Simone319 merged 1 commit into
mainfrom
fix/cdk-init-tsc-strip-failfast
Aug 5, 2026
Merged

fix(amplify-graphql-api-construct-tests): fail fast if cdk.json tsc-strip pattern stops matching#3520
Simone319 merged 1 commit into
mainfrom
fix/cdk-init-tsc-strip-failfast

Conversation

@Simone319

Copy link
Copy Markdown
Contributor

What

Adds a fail-fast guard to removeWholeProjectTypecheckFromSynth in packages/amplify-graphql-api-construct-tests/src/commands.ts. If the generated cdk.json app command still contains tsc but does not match the removal regex, we now throw with the actual command string instead of silently returning.

const appWithoutTypecheck = cdkJson.app.replace(/^\s*npx\s+tsc\s*&&\s*/, '');
if (appWithoutTypecheck === cdkJson.app) {
  if (cdkJson.app.includes('tsc')) {
    throw new Error(
      `[initCDKProject] cdk.json synth command still contains 'tsc' but did not match the removal pattern (the CDK CLI template likely ` +
        `changed): "${cdkJson.app}". Update this strip logic and/or CDK_CLI_VERSION (currently ${CDK_CLI_VERSION}).`,
    );
  }
  return;
}

Why

This applies the outstanding review feedback on #3519 (sarayev's suggestion). The strip logic is coupled to the exact app string the CDK CLI template emits. If a future CDK_CLI_VERSION bump changes that template (e.g. a different tsc invocation form), the regex silently stops matching and the whole-project typecheck quietly comes back — reintroducing the slow/failing synth that the strip exists to avoid, with no signal about why.

Failing loudly at initCDKProject time, with the offending command echoed and the current CDK_CLI_VERSION named, turns a silent regression into an immediately actionable error.

The no-tsc case still returns normally, so projects whose template legitimately has no typecheck step are unaffected.

Testing

  • packages/amplify-graphql-api-construct-tests compiles clean (tsc --build).
  • prettier --check passes on the changed file.

Notes

Split out of #3517 so this test-harness guard lands independently of the addCfnResourceDependency deprecation shim.

@Simone319
Simone319 merged commit 1b59fa1 into main Aug 5, 2026
7 of 8 checks passed
@Simone319
Simone319 deleted the fix/cdk-init-tsc-strip-failfast branch August 5, 2026 09:45
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.

2 participants