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

aws_cdk: Annotations do not render if they reference tokens #31786

Open
1 task
rittneje opened this issue Oct 16, 2024 · 1 comment
Open
1 task

aws_cdk: Annotations do not render if they reference tokens #31786

rittneje opened this issue Oct 16, 2024 · 1 comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@rittneje
Copy link

Describe the bug

If we add an annotation via aws_cdk.Annotations.of(x).add_error(...) where the error message is an f-string contain a token, then it does not print out the error message properly.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

It should at least try to print the actual message.

Current Behavior

It prints [object Object].

Reproduction Steps

    app = aws_cdk.App()
  
    env = aws_cdk.Environment(region="us-east-1")

    stack = aws_cdk.Stack(app, "test-stack", env=env)

    param = aws_ssm.StringParameter(stack, 'string-parameter', string_value='foobar')

    aws_cdk.Annotations.of(param).add_error(f"an error occurred: {param.env.account}")

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.161.0

Framework Version

No response

Node.js Version

v22.9.0

OS

Alpine 3.20.3

Language

Python

Language Version

3.12.7

Other information

No response

@rittneje rittneje added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 16, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ssm Related to AWS Systems Manager label Oct 16, 2024
@khushail khushail added needs-reproduction This issue needs reproduction. p2 and removed needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2024
@khushail khushail self-assigned this Oct 17, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-reproduction This issue needs reproduction. labels Oct 21, 2024
@khushail
Copy link
Contributor

khushail commented Oct 23, 2024

Hey @rittneje , thanks for reaching out. So I tried different variations for printing the error message, here is what I observed

  • since I mentioned the region in the code , that value is printed -
Screenshot 2024-10-22 at 3 07 33 PM

-but if I try to print the account value, its not printing anything (may be because the account is not resolved to anything as yet and would be given default value from config) -

Screenshot 2024-10-22 at 3 10 54 PM

This is how the method is implemented in CDK -

public addError(message: string) {

  /**
   * Adds an { "error": <message> } metadata entry to this construct.
   * The toolkit will fail deployment of any stack that has errors reported against it.
   * @param message The error message.
   */
  public addError(message: string) {
    this.addMessage(cxschema.ArtifactMetadataEntryType.ERROR, message);
  }

I did not find any workaround for this so marking this as P2 as passing normal string works.

Marking as P2 means team won't immediately look into it but it would be on their radar and this issue would also be open for community contribution. Hope that helps!

@khushail khushail added effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Oct 23, 2024
@khushail khushail removed their assignment Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants