fix(cdk): conditionally pass harnesses prop for CDK construct compat#1248
Conversation
The vended cdk-stack.ts passes `harnesses` to AgentCoreApplication, but the npm-published @aws/agentcore-cdk package doesn't have this prop in its interface. TypeScript strict mode rejects the unknown property at compile time, causing synth to fail and deploy to error with "NoStack". Fix by building props dynamically and casting, so the property is only present when harnesses are configured.
Coverage Report
|
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Fix looks correct — pragmatic workaround for the npm-published @aws/agentcore-cdk not yet exposing harnesses in its props type. Snapshot is in sync with the vended file. No blocking issues from my side.
One minor observation (non-blocking): the // eslint-disable-next-line @typescript-eslint/no-explicit-any comment on line 60/62 sits above const appProps: Record<string, unknown> = { spec };, but the as any it's meant to silence is on the new AgentCoreApplication(...) line a few lines below. Today this is harmless because src/assets is excluded from this repo's ESLint and the vended CDK project has no lint script — but if a downstream user adds linting with @typescript-eslint/no-explicit-any enabled, the comment won't disable the right line. Easy follow-up: move the comment directly above this.application = new AgentCoreApplication(...), or keep the original prop literal and just append as any to it (which would be shorter overall).
Worth considering a TODO/FIXME pointing at this so it can be ripped out once the npm package gains the harnesses prop.
Summary
Fixes e2e
http-gateway-targets.test.tsfailure on bothnpmandmainCDK variants.Preview's vended
cdk-stack.tspassesharnessestoAgentCoreApplication, but the npm-published@aws/agentcore-cdkpackage doesn't have this prop in its TypeScript interface. Withstrict: true, the CDK app fails to compile during synth, producing no stack — then deploy errors withNoStack: CloudFormationStack object does not hold a stack.Fix: build the
AgentCoreApplicationprops dynamically and cast, so theharnessesproperty is only present when harnesses are actually configured.Test plan
http-gateway-targets.test.tspasses on bothnpmandmainvariants