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

CloudWatchEvents.ScheduledEvent cannot be used with EventBridge Scheduler #1864

Open
1 task
Dreamescaper opened this issue Nov 8, 2024 · 7 comments
Open
1 task
Assignees
Labels
bug This issue is a bug. module/lambda-client-lib p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@Dreamescaper
Copy link
Contributor

Dreamescaper commented Nov 8, 2024

Describe the bug

Attempting to use ScheduledEvent with EventBridge Scheduler fails due to JSON Serialization.

Regression Issue

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

Expected Behavior

I am able to use ScheduledEvent with EventBridge Scheduler.

Current Behavior

Error converting the Lambda event JSON payload to type Amazon.Lambda.CloudWatchEvents.ScheduledEvents.ScheduledEvent: The JSON value could not be converted to Amazon.Lambda.CloudWatchEvents.ScheduledEvents.Detail. Path: $.detail | LineNumber: 0 | BytePositionInLine: 339.

Additional Information/Context

Here's the event I'm receiving:

{
    "version": "0",
    "id": "49672d39-8c3a-4cc6-8de5-c57b0acf718f",
    "detail-type": "Scheduled Event",
    "source": "aws.scheduler",
    "account": "12345",
    "time": "2024-11-07T22:05:00Z",
    "region": "eu-central-1",
    "resources": [
        "arn:aws:scheduler:eu-central-1:12345:schedule/default/test-schedule"
    ],
    "detail": "{}"
}

It is very-very similar to what we have in ScheduledEvent. However, "detail" here is a string, not a json object.

According to
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events-structure.html
"detail" should be a JSON object, but "{}". I have no idea why such string is allowed, or whether any other stringified JSON is possible there.

Possible Solution

Write JSON converter, which allows Detail to be string (either allow empty object string only "{}", or a full stringified JSON object - not sure).

AWS .NET SDK and/or Package version used

Amazon.Lambda.CloudWatchEvents 4.4.0

Targeted .NET Platform

.NET 8

Operating System and version

AmazonLinux

@Dreamescaper Dreamescaper added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 8, 2024
@bhoradc bhoradc added needs-reproduction This issue needs reproduction. module/lambda-client-lib p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Nov 8, 2024
@ashishdhingra
Copy link
Contributor

  • Per AWS service event metadata, detail is a JSON object that contains information about the event. The service generating the event determines the content of this field. It can be "{}".
  • Per Amazon EventBridge events detail reference, detail is JSON object that contains information about the event. The service generating the event determines the content of this field. It is a Required field. There are no required fields in this object for Scheduled Event events.

Since the service generating the event determines the content of this field, the Detail class is correctly modeled as class without fields.

{} should be considered as an empty JSON object.

@Dreamescaper
Copy link
Contributor Author

Is there any information why string "{}" is used instead of an empty object {}?

@ashishdhingra ashishdhingra self-assigned this Nov 13, 2024
@ashishdhingra
Copy link
Contributor

Reproducible using payload provided by customer. Unsure why in AWS service event metadata, for detail, is states A JSON object that contains information about the event. The service generating the event determines the content of this field. It can be "{}"..

Just FYI, Java Lambda event POCO class ScheduledEvent represents detail of type Map<String, Object> here. So it would essentially also fail.

@Dreamescaper In your use case, are you actually receiving "{}" instead of {} (empty JSON object)? Or are you pointing to issue in above documentation? In either case, we would need to reach out to service team for their inputs.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. needs-review and removed needs-reproduction This issue needs reproduction. labels Nov 16, 2024
@Dreamescaper
Copy link
Contributor Author

Dreamescaper commented Nov 16, 2024

@ashishdhingra
Yes, I'm actually receiving string "{}"

@Dreamescaper
Copy link
Contributor Author

@ashishdhingra
Btw, java package had the same issue logged:
aws/aws-lambda-java-libs#479

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to close soon in 7 days. label Nov 17, 2024
@ashishdhingra
Copy link
Contributor

@ashishdhingra Btw, java package had the same issue logged: aws/aws-lambda-java-libs#479

@Dreamescaper Thanks for sharing the information. I have opened ticket with Lambda team.

Internal Ticket: P170893989

@ashishdhingra ashishdhingra added the service-api This issue is due to a problem in a service API, not the SDK implementation. label Nov 18, 2024
@ashishdhingra
Copy link
Contributor

@Dreamescaper Thanks for sharing the information. I have opened ticket with Lambda team.

Internal Ticket: P170893989
@Dreamescaper We have opened ticket with service team for inputs. In the meanwhile, you may use CloudWatchEvent<string> instead of CloudWatchEvents.ScheduledEvent for your use case.

Thanks,
Ashish

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. module/lambda-client-lib p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

3 participants