localstack / localstack

💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
https://localstack.cloud
Other
56.36k stars 4.02k forks source link

bug: EventBridge Scheduler CreateSchedule operation not validating ScheduleExpression #9284

Open KrazyK786 opened 1 year ago

KrazyK786 commented 1 year ago

Is there an existing issue for this?

Current Behavior

When creating EventBridge Schedule with the CreateSchedule operation, passing an invalid ScheduleExpression is still successful

Expected Behavior

Calling CreateSchedule with an invalid ScheduleExpression should return:

ValidationException: Invalid Schedule Expression <expression>

How are you starting LocalStack?

Custom (please describe below)

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run localstack/localstack (via Testcontainers for Go)

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

import (
    "fmt"
    "time"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/scheduler"
)

mySession := session.Must(session.NewSession())
svc := scheduler.New(mySession, aws.NewConfig().WithEndpoint("http://localhost:4566").WithRegion("us-east-2"))

interval := time.Hour * 24
cTime := time.Now()

_, err := svc.CreateSchedule(&scheduler.CreateScheduleInput{
    Name: aws.String("Test Schedule"),
    FlexibleTimeWindow: &scheduler.FlexibleTimeWindow{
    Mode: aws.String("OFF"),
    },
    ScheduleExpression:         aws.String(cTime.Add(interval).Format("2006-01-02T15:04:05")),  // invalid
    ScheduleExpressionTimezone: aws.String("America/Los_Angeles"),
    Target: &scheduler.Target{
    RoleArn: aws.String("arn:aws:iam::000000000000:root"),
    Arn:     aws.String("arn:aws:lambda:us-east-2:000000000000:function:test-lambda-function"),
    },
    ActionAfterCompletion: aws.String("DELETE"),
})
if err != nil {
    return err
}

actualSchedule, err := svc.GetSchedule(&scheduler.GetScheduleInput{
    Name: aws.String("Test Schedule"),
})
if err != nil {
    return err
}

fmt.Println("Expression: ", *actualSchedule.ScheduleExpression)  // prints: Expression:  2023-10-04T21:54:24

Running these same steps against AWS returns:

ValidationException: Invalid Schedule Expression 2023-10-04T21:54:24

Environment

- OS: MacOS Ventura 13.5.2
- LocalStack:latest

Anything else?

localstack-bot commented 8 months ago

Hello 👋! It looks like this issue hasn’t been active in longer than five months. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

KrazyK786 commented 8 months ago

To confirm, retested with latest release and the issue still occurs ☹️

KrazyK786 commented 2 months ago

Retested today after seeing the other EventBridge issue was resolved, but still seeing the invalid expression validate successfully