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

fix(lambda): use enum values for applicationLogLevel and systemLogLevel #29904

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dali546
Copy link

@dali546 dali546 commented Apr 19, 2024

Issue # (if applicable)

Reason for this change

Enumerate ApplicationLogLevel and SystemLogLevel to help with typing

Description of changes

Both fields should use the enum type for available options

Description of how you validated changes

Checklist


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 Apr 19, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team April 19, 2024 10:23
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Apr 19, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@dali546
Copy link
Author

dali546 commented Apr 21, 2024

Exemption Request: minor typescript change

@aaythapa aaythapa self-assigned this Apr 22, 2024
@aaythapa
Copy link
Contributor

Hi @dali546, thanks for making this change! Not sure why it wasn't an enum before. I'll have to double check to see if this is backwards compatible. In the meantime looks like the build step is failing because the some integration test snapshots need updates. You can use yarn integ --update-on-failed to update the integ snapshots.

@dali546
Copy link
Author

dali546 commented Apr 22, 2024

Hi @aaythapa, thank you for taking a look at this PR... I've cloned down this repo, but unsure where to run yarn integ --update-on-failed? And it also suggests I should be authenticated with AWS for this too? Is this something I should be doing as a external contributor?

@aaythapa
Copy link
Contributor

aaythapa commented Apr 22, 2024

Hi @dali546, looking through the build log and I see API elements with incompatible change, this basically means that this PR in its current state is backwards incompatible :(.

You can enforce the enum type by making a new property (maybe called systemLogLevelV2) and have that property use the enum. You'd then deprecate the old systemLogLevel property. This would also fix the build failures you're seeing in the PR but you'd still have to add some integ tests.

This PR pretty much fixes the same issue you're trying to fix so feel free to use it as reference (note this PR doesn't deprecate the old property for some reason, this pr is a good example of adding a deprecated label). You can use our integ test guide to add new integ tests.

@dali546
Copy link
Author

dali546 commented Apr 24, 2024

Hi @aaythapa. I need a little help. Locally I am trying to run yarn run integ-runner --update-on-failed --directory packages/@aws-cdk-testing/test/aws-lambda but my results show as UNCHANGED for all of them. it's not generating a new snapshot

Any advice?

@aaythapa
Copy link
Contributor

Hi @dali546, sorry about the delay. Not sure what the exact issue could be. You can try deleting the snapshot folder for the test and re-making it. I see that integ.logging-config.js test is failing, so you can delete that tests snapshot folder and re-run so it creates a new folder, hopefully the different snapshot will show up.

@aws-cdk-automation aws-cdk-automation dismissed their stale review April 30, 2024 22:02

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 30, 2024
@dali546 dali546 requested a review from aaythapa May 4, 2024 21:14
@dali546 dali546 force-pushed the patch-1 branch 2 times, most recently from bac94f7 to f027aeb Compare May 6, 2024 13:18
Copy link
Contributor

@aaythapa aaythapa left a comment

Choose a reason for hiding this comment

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

@dali546 looks good, just some small final comments.

systemLogLevelV2: lambda.SystemLogLevel.WARN,
});
}).toThrow(/Only define systemLogLevel or systemLogLevelV2, not both./);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add one more test for the case where systemLogLevelV2 or applicationLogLevelV2 is set but loggingFormat isn't set to LoggingFormat.JSON

code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_18_X,
logFormat: lambda.LogFormat.JSON,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you use loggingFormat here too

@aaythapa aaythapa changed the title fix: use enum values for applicationLogLevel and systemLogLevel fix(lambda): use enum values for applicationLogLevel and systemLogLevel May 8, 2024
@aaythapa
Copy link
Contributor

aaythapa commented May 9, 2024

@mergify update

Copy link
Contributor

mergify bot commented May 9, 2024

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 3e8b49d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants