Skip to content

Conversation

@mrgrain
Copy link
Contributor

@mrgrain mrgrain commented Mar 5, 2025

Adds many more explicit codes and message payload to messages that previously were default messages.

Within toolkit-lib replace all previous message helpers with the new Message Maker pattern: CODES.CDK_CAT_I1234.msg("my message").


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 5, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 5, 2025 13:26
@github-actions github-actions bot added the p2 label Mar 5, 2025
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.22%. Comparing base (b242c23) to head (6709ded).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #193      +/-   ##
==========================================
+ Coverage   85.02%   85.22%   +0.19%     
==========================================
  Files         207      207              
  Lines       35706    35706              
  Branches     4636     4636              
==========================================
+ Hits        30360    30431      +71     
+ Misses       5188     5123      -65     
+ Partials      158      152       -6     
Flag Coverage Δ
suite.unit 85.22% <ø> (+0.19%) ⬆️

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

export const warn = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('warn', details);
export const error = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('error', details);
export const result = <T extends object>(details: Required<CodeInfo>) => generic<T extends object ? T : never>('result', details);
export const result = <T extends object = ImpossibleType>(details: Required<CodeInfo>) => generic<T extends object ? T : never>('result', details);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this, attempting to post a result message without data will now fail at compile time. Unfortunately it's not possible in TS to mark a generic type as required. Instead we are defaulting to a type that is impossible for a user to create, and thus their code will always fail unless a different generic is provided.

@mrgrain mrgrain force-pushed the mrgrain/feat/emit-more-structured-data branch 5 times, most recently from 3f26818 to 1e6fb5e Compare March 6, 2025 09:42
Copy link
Contributor Author

@mrgrain mrgrain Mar 6, 2025

Choose a reason for hiding this comment

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

these were just moved into a separate file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

split into 2 separate files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in favor of using CODES.CDK_ASSEMBLY_I0150.msg()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

split out from other file

this._sdkProvider = await SdkProvider.withAwsCliCompatibleDefaults({
...this.props.sdkConfig,
logger: asSdkLogger(this.ioHost, action),
logger: asSdkLogger(withAction(this.ioHost, action)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

small refactor so the private SdkLogger can just take an ActionAwareIoHost. This makes life much easier inside the SdkLogger

Comment on lines +22 to +33
DEFAULT_TOOLKIT_INFO: make.info({
code: 'CDK_TOOLKIT_I0000',
description: 'Default info messages emitted from the Toolkit',
}),
DEFAULT_TOOLKIT_DEBUG: make.debug({
code: 'CDK_TOOLKIT_I0000',
description: 'Default debug messages emitted from the Toolkit',
}),
DEFAULT_TOOLKIT_WARN: make.warn({
code: 'CDK_TOOLKIT_W0000',
description: 'Default warning messages emitted from the Toolkit',
}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are some generic messages without data that don't deserve a special code. Usually because there already is a message with data preceding it.

const cloudWatchLogMonitor = options.traceLogs ? new CloudWatchLogEventMonitor() : undefined;
const deployAndWatch = async () => {
latch = 'deploying';
latch = 'deploying' as LatchState;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes L636 a bit more readable.

@mrgrain mrgrain force-pushed the mrgrain/feat/emit-more-structured-data branch from 1e6fb5e to f2a26c8 Compare March 6, 2025 09:56
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in favor of using CODES.CDK_ASSEMBLY_I0150.msg()

Copy link
Contributor Author

@mrgrain mrgrain Mar 6, 2025

Choose a reason for hiding this comment

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

Test changed on purpose. I upgraded this particular message from info to result as it's the main outcome of the destroy action. This is fine because the message was previously uncoded (i.e. using a default code) and we explicitly allow that.

@mrgrain mrgrain marked this pull request as ready for review March 6, 2025 10:01
CDK_TOOLKIT_I7900: make.result<cxapi.CloudFormationStackArtifact>({
code: 'CDK_TOOLKIT_I7900',
description: 'Stack deletion succeeded',
interface: 'cxapi.CloudFormationStackArtifact',
Copy link
Contributor

Choose a reason for hiding this comment

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

already discussed but note that this will result in a bad link in the CODE_REGISTRY

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Acceptable right now. Will fix later.

const assembly = await assemblyFromSource(cx, false);
const ioHost = withAction(this.ioHost, 'watch');
const rootDir = options.watchDir ?? process.cwd();
await ioHost.notify(debug(`root directory used for 'watch' is: ${rootDir}`));
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove these comments from watch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are moved further down to be emitted as a single message.

@iliapolo iliapolo disabled auto-merge March 6, 2025 16:39
Co-authored-by: Eli Polonsky <[email protected]>
@kaizencc kaizencc enabled auto-merge March 6, 2025 16:51
Signed-off-by: github-actions <[email protected]>
@kaizencc kaizencc added this pull request to the merge queue Mar 6, 2025
Merged via the queue into main with commit a3160a7 Mar 6, 2025
11 checks passed
@kaizencc kaizencc deleted the mrgrain/feat/emit-more-structured-data branch March 6, 2025 17:19
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.

4 participants