8000 bug: EventBridge Scheduler CreateSchedule operation not validating ScheduleExpression · Issue #9284 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content
bug: EventBridge Scheduler CreateSchedule operation not validating ScheduleExpression #9284
Closed
@KrazyK786

Description

@KrazyK786

Is there an existing issue for this?

  • I have searched the existing issues

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?

  • The example uses a one-time schedule, but the behavior was observed with a bad cron expression as well
  • Running the example against AWS with an expression like below is successful:
...
ScheduleExpression:  aws.String(fmt.Sprintf("at(%v)", cTime.Add(interval).Format("2006-01-02T15:04:05"))),
...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0