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(events-targets): add LogGroupTargetInput.fromObjectV2() method #33720

Merged
merged 12 commits into from
Mar 11, 2025

Conversation

paulhcsun
Copy link
Contributor

@paulhcsun paulhcsun commented Mar 10, 2025

Reason for this change

The LogGroupTargetInput.fromObject() function returns a RuleTargetInput instead of a LogGroupTargetInput. It can therefore not be passed into the following field:

export interface LogGroupProps extends TargetBaseProps {
  // ...
  readonly logEvent?: LogGroupTargetInput;
}

Because the types don't match.

This is a bug that hasn't shown up in TypeScript before because according to TypeScript's structural typing rules, the types RuleTargetInput and LogGroupTargetInput are compatible, but according to Java's nominal typing rules they are not.

Description of changes

Deprecated LogGroupTargetInput.fromObject() and created LogGroupTargetInput.fromObjectV2() which returns the correct type of LogGroupTargetInput.

Description of how you validated changes

integ test

Checklist


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

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
ssbarnea Sorin Sbarnea
@github-actions github-actions bot added the p2 label Mar 10, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 10, 2025 16:52
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 10, 2025
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.

(This review is outdated)

@paulhcsun paulhcsun added the pr-linter/exempt-readme The PR linter will not require README changes label Mar 10, 2025
@paulhcsun paulhcsun changed the title feat(events-targets): add LogGroupTargetInput.fromObjectV2() method fix(events-targets): add LogGroupTargetInput.fromObjectV2() method Mar 10, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 10, 2025 16:55

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

@paulhcsun paulhcsun removed the pr-linter/exempt-readme The PR linter will not require README changes label Mar 10, 2025
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.37%. Comparing base (3de0818) to head (c1dc834).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33720   +/-   ##
=======================================
  Coverage   82.37%   82.37%           
=======================================
  Files         120      120           
  Lines        6933     6933           
  Branches     1169     1169           
=======================================
  Hits         5711     5711           
  Misses       1119     1119           
  Partials      103      103           
Flag Coverage Δ
suite.unit 82.37% <ø> (ø)

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

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 82.37% <ø> (ø)
🚀 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.

paulhcsun and others added 2 commits March 10, 2025 13:22
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.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review March 10, 2025 20:29

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

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.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation dismissed their stale review March 10, 2025 21:04

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

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 10, 2025
@5d
Copy link
Member

5d commented Mar 11, 2025

Just a general question, following the conventional approach, have you considered making logEvent in LogGroupProps an interface and then having RuleTargetInput and LogGroupTargetInput implement that interface?

* matched event.
*/
public static fromObjectV2(options?: LogGroupTargetInputOptions): LogGroupTargetInput {
return RuleTargetInput.fromObjectV2({
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be LogGroupTargetInput.fromObjectV2()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily but I don't think I need the duplicate V2 method in RuleTargetInput. I've updated this method in the latest commit.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Mar 11, 2025
@paulhcsun
Copy link
Contributor Author

Thanks for review @5d. I'm not able to change the type of logEvent because it's getting passed into the bind method here:

input: this.props.event ?? this.props.logEvent,
and if the type is changed then that call won't work anymore.

paulhcsun and others added 4 commits March 11, 2025 10:08
@paulhcsun
Copy link
Contributor Author

@merigyfio update

@paulhcsun
Copy link
Contributor Author

@Mergifyio update

Copy link
Contributor

mergify bot commented Mar 11, 2025

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Mar 11, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 584a58c into aws:main Mar 11, 2025
20 checks passed
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants