You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds 19 CDK synthesis smoke tests that validate agentcore.json spec shapes can be synthesized into valid CloudFormation templates via AgentCoreStack → AgentCoreApplication L3 construct
I've completed a thorough review of this PR. While the test coverage is comprehensive, there are several issues that need to be addressed before this can be merged.
Every PR must be linked to an issue. Open an issue first (or find an existing one) and reference it in your PR using Closes #issue-number. PRs without an associated issue will not be reviewed.
Action Required: Add a Closes #<issue-number> link to the PR description.
2. Tests Are Excluded from CI ⚠️[MUST FIX]
The test file is explicitly excluded from the unit test suite in vitest.config.ts line 43:
Impact: These tests will never run in CI. The PR description claims the tests pass, but they won't execute automatically.
Questions:
Why are these tests excluded from the unit project?
Should they be in a different test project (e.g., integ)?
Is there a performance concern that requires exclusion?
The git history shows a commit f9fb8ab: "fix: exclude CDK synth tests from CI unit suite" which suggests this was intentional, but without context it's unclear if this is the right approach.
Action Required: Either:
Remove the exclusion so tests run in CI, OR
Add these tests to an appropriate test project, OR
Document why they should be excluded and how they'll be run
🔴 CRITICAL Issues
3. Weak Assertions - Not Validating Correctness
Many tests use Match.anyValue() which only checks that a resource exists, not that it's configured correctly:
Count: 17 instances of Match.anyValue() across the test file.
Why this matters: These tests won't catch misconfiguration bugs. For example:
ECR repository with wrong lifecycle policy
IAM role with incorrect trust policy
Missing required properties
Recommendation:
// Instead of:template.hasResourceProperties(CFN_ECR_REPO,Match.anyValue());// Use specific assertions:template.hasResourceProperties(CFN_ECR_REPO,{RepositoryName: Match.stringLikeRegexp('containeragent'),ImageScanningConfiguration: Match.objectLike({ScanOnPush: true})});
4. Excessive Type Casting Bypasses Type Safety
Count: 35 uses of as never throughout the test file.
Example from line 204:
agents: [makeAgent('myagent')]asnever,
Why this is problematic:
Bypasses TypeScript's type checking completely
Could hide real type mismatches between test data and actual spec types
Makes tests less valuable for catching schema drift
Root cause: The helper functions return plain objects that may not match the exact Zod-validated types.
Recommendation:
// Option 1: Use proper types from the schemaimporttype{AgentEnvSpec}from'@aws/agentcore-cdk';functionmakeAgent(name: string,overrides: Partial<AgentEnvSpec>={}): AgentEnvSpec{return{type: 'AgentEnvironment',
name,build: 'CodeZip',// ... rest of properties with proper typing};}// Option 2: If types are complex, at least use `as unknown as AgentEnvSpec[]`// instead of `as never` to maintain some type safety
💡 SUGGESTIONS (Non-blocking)
5. Extract Test Utilities to Shared Module
The helper functions (makeAgent, makeMemory, makeEvaluator, etc.) could be valuable for other CDK-related tests.
Recommendation: Create src/assets/__tests__/helpers/cdk-test-utils.ts with these utilities.
6. Add Negative Test Cases
All current tests verify successful synthesis. Consider adding tests for:
Invalid agent configurations that should fail
Missing required fields
Invalid memory strategy combinations
Schema validation errors
Example:
it('fails to synthesize agent with missing codeLocation',()=>{expect(()=>{synthStack(baseSpec({agents: [{type: 'AgentEnvironment',name: 'test'}]asnever,}));}).toThrow();});
✅ No security issues (no secrets, safe temp dir usage)
✅ Edge case coverage (max name lengths, standalone resources)
✅ Clean helper functions reduce duplication
📋 Action Items
Must Fix Before Merge:
Add linked issue reference (Closes #XXX) to PR description
Resolve test exclusion: either remove exclusion, add to appropriate project, or document why excluded
Replace Match.anyValue() with specific assertions for key properties
Fix excessive as never casting with proper types
Recommended:
Extract test utilities to shared module
Add negative test cases for error scenarios
Use stable stack naming
Document test exclusion rationale
Verdict
Cannot approve until blocking issues #1 and #2 are resolved. The test coverage is good in principle, but the tests won't run in CI (issue #2) and the PR doesn't meet contribution guidelines (issue #1). Issues #3 and #4 significantly reduce the value of these tests and should be addressed to make them more robust.
@aws/agentcore-cdk is npm-linked locally, not available in CI.
Exclude the test from the unit project, matching the existing
exclusion pattern for src/assets/cdk/test/*.test.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agentcore.jsonspec shapes can be synthesized into valid CloudFormation templates viaAgentCoreStack→AgentCoreApplicationL3 construct@aws/agentcore-cdkresolve alias invitest.config.tsto handle CJS-only package exports in ViteTest plan
npx vitest run src/assets/__tests__/cdk-synth-validation.test.ts)