Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(toolkit): Warning/Errors added using constructs.ConstructMetadata keys type are ignored #8645

Closed
NetaNir opened this issue Jun 19, 2020 · 3 comments
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Milestone

Comments

@NetaNir
Copy link
Contributor

NetaNir commented Jun 19, 2020

Warning/error/info messages that are collected during synth will only be printed out by the toolkit if their type in the metadata array is prefixed with aws:cdk: (see code). Since metadata added via constructs uses the ConstructMetadata keys which does not include the aws:cdk: prefix:

/**
 * Metadata keys used by constructs.
 */
export class ConstructMetadata {
  /**
   * If set in the construct's context, omits stack traces from metadata entries.
   */
  public static readonly DISABLE_STACK_TRACE_IN_METADATA = 'disable-stack-trace';

  /**
   * Context type for info level messages.
   */
  public static readonly INFO_METADATA_KEY = 'info';

  /**
   * Context type for warning level messages.
   */
  public static readonly WARNING_METADATA_KEY = 'warning';

  /**
   * Context type for error level messages.
   */
  public static readonly ERROR_METADATA_KEY = 'error';

  private constructor() { }
}

will not be printed out by the toolkit.

To give more debug context, this happens since renderMessage method in CloudArtifact use the cxschema.ArtifactMetadataEntryType keys to collect the messages from the metadata array which all includes the aws:cdk: prefix, meaning other types will be ignored (e,g warning will be ignored but aws:cdk:warning will be added).

Is this by design? From the docs in constructs it does not seem like it:

  /**
   * Adds a { "info": <message> } metadata entry to this construct.
   * The toolkit will display the info message when apps are synthesized.
   * @param message The info message.

code

Environment

  • CDK CLI Version:
  • Module Version:
  • Node.js Version:
  • OS:
  • Language (Version):
@NetaNir NetaNir added the needs-triage This issue or PR still needs to be triaged. label Jun 19, 2020
@SomayaB SomayaB added package/tools Related to AWS CDK Tools or CLI and removed needs-triage This issue or PR still needs to be triaged. labels Jun 19, 2020
@SomayaB SomayaB added the bug This issue is a bug. label Jul 9, 2020
@iliapolo
Copy link
Contributor

@NetaNir It looks like an oversight, definitely not intended.

We should take this into account if the constructs-compat removal RFC: aws/aws-cdk-rfcs#195

@iliapolo
Copy link
Contributor

See aws/aws-cdk-rfcs#195 (comment)

@iliapolo iliapolo added the p1 label Jul 10, 2020
@rix0rrr rix0rrr added this to the [CLI] Soon milestone Aug 13, 2020
@iliapolo iliapolo assigned rix0rrr and unassigned iliapolo Aug 20, 2020
@rix0rrr rix0rrr added the effort/small Small work item – less than a day of effort label Aug 27, 2020
@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

5 participants