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-stepfunctions-tasks: EventBridge aws. event source prefix check is more strict than it should be #30191

Closed
FilipPyrek opened this issue May 14, 2024 · 3 comments · Fixed by #30237
Labels
@aws-cdk/aws-stepfunctions-tasks bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@FilipPyrek
Copy link

Describe the bug

We discovered that the EventBridgePutEvents is throwing an error even in cases when it's not necessary to throw.

For example our source looks like this aws-some-feature.this.that and according to the docs this should be valid.

All events that come from AWS services begin with "aws."

Whereas in the CDK code of EventBridgePutEvents is this check

if (entry.source?.startsWith('aws')) {

The correct implementation should be following

if (entry.source?.startsWith('aws.')) {

Expected Behavior

EventBridgePutEvents should not throw an error when source starts with aws. (but not just aws)

Current Behavior

EventBridgePutEvents throws an error when source starts with aws

Reproduction Steps

Use this task in a state machine.

import { EventBridgePutEvents } from 'aws-cdk-lib/aws-stepfunctions-tasks'

new EventBridgePutEvents(
  this,
  'SendEvent',
  {
    entries: [
      {
        eventBus: 'some-event-bus',
        source: `aws-feature-name-whatever-you-want`,
        detailType: 'some-detail',
        detail: TaskInput.fromJsonPathAt('$')
      }
    ]
  }
)

Possible Solution

Change this line: https://github.com/aws/aws-cdk/blob/205163fc0d2cac84d3d746a98c393e137f0e2388/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/eventbridge/put-events.ts#L136C7-L136C45

to:

- if (entry.source?.startsWith('aws')) {
+ if (entry.source?.startsWith('aws.')) { 

Additional Information/Context

No response

CDK CLI Version

v2.141.0

Framework Version

No response

Node.js Version

20.x

OS

MacOS (personal) / Ubuntu (in CI)

Language

TypeScript

Language Version

5.4.5

Other information

No response

@FilipPyrek FilipPyrek added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 14, 2024
@pahud
Copy link
Contributor

pahud commented May 16, 2024

Makes perfect sense to me. Thank you for the report.

@pahud pahud added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels May 16, 2024
@mergify mergify bot closed this as completed in #30237 Jun 6, 2024
mergify bot pushed a commit that referenced this issue Jun 6, 2024
… is more strict than it should be (#30237)

1. fix the event source validation
2. move the validation from renderEntries() to validateEntries() 
3. add unit tests

### Issue # (if applicable)

Closes #30191

### Reason for this change



### Description of changes



### Description of how you validated changes



### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

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

github-actions bot commented Jun 6, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Leo10Gama pushed a commit to Leo10Gama/aws-cdk that referenced this issue Jun 11, 2024
… is more strict than it should be (aws#30237)

1. fix the event source validation
2. move the validation from renderEntries() to validateEntries() 
3. add unit tests

### Issue # (if applicable)

Closes aws#30191

### Reason for this change



### Description of changes



### Description of how you validated changes



### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mazyu36 pushed a commit to mazyu36/aws-cdk that referenced this issue Jun 22, 2024
… is more strict than it should be (aws#30237)

1. fix the event source validation
2. move the validation from renderEntries() to validateEntries() 
3. add unit tests

### Issue # (if applicable)

Closes aws#30191

### Reason for this change



### Description of changes



### Description of how you validated changes



### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-stepfunctions-tasks bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
3 participants