Skip to content

feat(cli): cdk validate command (behind --unstable flag)#1527

Open
kaizencc wants to merge 11 commits into
mainfrom
conroyka/cli-validate
Open

feat(cli): cdk validate command (behind --unstable flag)#1527
kaizencc wants to merge 11 commits into
mainfrom
conroyka/cli-validate

Conversation

@kaizencc
Copy link
Copy Markdown
Contributor

@kaizencc kaizencc commented May 18, 2026

Wires up cdk validate as a CLI command behind the --unstable=validate feature flag. The command synthesizes the app, reads the policy validation report JSON from the cloud assembly, and renders results using a new formatter.

Screenshot 2026-05-18 at 12 10 08 PM

Changes

  • cli-config.ts — Adds validate command definition with STACKS variadic arg
  • cli.ts — Adds case validate handler, sets @aws-cdk/core:validationReportOnly context to suppress synthesis-time reporting (depends on aws-cdk#37909)
  • cdk-toolkit.ts — Adds validate() method that delegates to this.toolkit.validate()
  • validate-formatting.ts — New formatter that renders violations grouped by severity with construct paths, source locations, and acknowledge instructions
  • toolkit.ts — Adds validate to UnstableFeature, uses hostMessageFromValidation helper

Dependencies


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions Bot added the p2 label May 18, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team May 18, 2026 18:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@kaizencc kaizencc force-pushed the conroyka/validate branch from 72951bb to 152e026 Compare May 20, 2026 17:43
Base automatically changed from conroyka/validate to main May 20, 2026 18:30
@kaizencc kaizencc deployed to automation May 20, 2026 18:30 — with GitHub Actions Active
kaizencc and others added 10 commits May 20, 2026 14:39
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…lidate

Instead of redefining the policy validation report types locally,
import them from @aws-cdk/cloud-assembly-schema (added in PR #1515).
This removes ~130 lines of duplicate type definitions and simplifies
the validate method to a typed cast instead of manual field mapping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Handle malformed report: throw ToolkitError if pluginReports is
  missing or not an array
- Test constructStack (ConstructTraceJson): add recursive trace to
  fixture and assert nested id/construct/location fields
- Assert IO message data payload contains full ValidateResult
- Test missing title field gracefully results in undefined

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace 'as const' with explicit PolicyValidationReportStatus type annotation
- Extract 'policy-validation-report.json' to a file-level constant

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lidate

- Overhaul validate-formatting: severity+description bold with color
  (red=fatal, orange=error, yellow=warning/info/custom), construct path
  bold, source location extracted to file:line:col format
- Support info and custom severity levels with proper sort ordering
- Use info-level IO to avoid CLI wrapping output in red
- Set @aws-cdk/core:validationReportOnly context before synth
- Add VALIDATE to Command enum and regenerate CLI parser files
- Add integ test fixture (SecurityPlugin + Construct Annotations + ack)
- Add 3 integ tests (violations, passes, acknowledge suppresses)
- Add static multi-plugin fixture for formatter testing
Update the validate command implementation and tests to use the
actual types from the cloud-assembly-schema package (PR #1515):
- PolicyValidationReportStatus → PolicyValidationReportConclusion
- status → conclusion
- summary.pluginName → pluginName
- fix → suggestedFix
- constructStack → stackTraces
- resourceLogicalId/templatePath/locations → cloudFormationResource
- Use Manifest.loadValidationReport for schema-validated loading
- Update all test fixtures to match the validation report schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant