Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Mar 4, 2025

Previously the declared level and payload interfaces were only loosely coupled to actual messages being created. This caused a number of issues with incorrectly documented levels and payload interfaces.

Instead of the previous approach, the code registry is now providing a strongly typed "message builder" function specific to every registered code. This function uses generics, so it can correctly ensure at build time that payloads are as expected.

This is the first PR of this series to keep the diff small. Next steps will be to make the code registry available to the CLI package and to remove the old helpers for creating messages.


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

@mrgrain mrgrain added the pr/exempt-integ-test Skips the integ test steps if set. label Mar 4, 2025
@github-actions github-actions bot added the p2 label Mar 4, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 4, 2025 18:39
const code = `CDK_${category}_${levelIndicator}0000` as IoMessageCode;
return {
code,
description: `Generic ${level} message for CDK_${category}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wasn't used and only existed to satisfy the interface

@mrgrain mrgrain force-pushed the mrgrain/chore/enforce-correct-code-level-payload branch from a081ae8 to 1f4780a Compare March 4, 2025 18:46
@mrgrain mrgrain force-pushed the mrgrain/chore/enforce-correct-code-level-payload branch from 1f4780a to f51ec4a Compare March 4, 2025 18:51
@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.00%. Comparing base (01acccf) to head (04b1f8b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
+ Coverage   84.95%   85.00%   +0.04%     
==========================================
  Files         207      207              
  Lines       35723    35723              
  Branches     4612     4601      -11     
==========================================
+ Hits        30348    30365      +17     
+ Misses       5220     5207      -13     
+ Partials      155      151       -4     
Flag Coverage Δ
suite.unit 85.00% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iliapolo iliapolo disabled auto-merge March 5, 2025 10:33
Copy link
Contributor

@iliapolo iliapolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dequeued to address minor comments.

* An IoHost wrapper that adds the given action to an actionless message before
* sending the message to the given IoHost
*/
export function withAction(ioHost: IIoHost, action: ToolkitAction): ActionAwareIoHost {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we already have this function here:

export function withAction(ioHost: IIoHost, action: ToolkitAction) {

Can we reuse?

/**
* The current action being performed by the CLI. 'none' represents the absence of an action.
*/
export type ToolkitAction =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but it just caught my so putting it out here. This list is slightly different than then one in the CLI. Intentional?

export type ToolkitAction =
| 'assembly'
| 'bootstrap'
| 'synth'
| 'list'
| 'diff'
| 'deploy'
| 'rollback'
| 'watch'
| 'destroy'
| 'context'
| 'docs'
| 'doctor'
| 'gc'
| 'import'
| 'metadata'
| 'notices'
| 'init'
| 'migrate'
| 'version';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the CLI has more. To be unified soon.

@mrgrain mrgrain enabled auto-merge March 5, 2025 11:13
@mrgrain mrgrain added this pull request to the merge queue Mar 5, 2025
Merged via the queue into main with commit 2f0caf4 Mar 5, 2025
11 checks passed
@mrgrain mrgrain deleted the mrgrain/chore/enforce-correct-code-level-payload branch March 5, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p2 pr/exempt-integ-test Skips the integ test steps if set.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants