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

Publishing an incomplete event does not return an error #2296

Open
matt2e opened this issue Aug 8, 2024 · 0 comments
Open

Publishing an incomplete event does not return an error #2296

matt2e opened this issue Aug 8, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@matt2e
Copy link
Contributor

matt2e commented Aug 8, 2024

  • Publishing to a topic has no checks for whether the event can be unmarshalled (eg missing value for field)
  • When subscriptions try consuming the event is when the errors start appearing
  • This is more of a publishing error not a subscription error so we should try to surface this at the time of publication

Steps to repro

Write the following code:

//ftl:data
type Event struct {
    Id string `json:"id"`
    Name string `json:"name,omitempty"`
}

var Topic = ftl.Topic[Event]("topic")
var _ = ftl.Subscription(Topic, "sub")

//ftl:verb
func Publish(ctx context.Context) error {
    err := Topic.Publish(ctx, Event{
        Id: "abc",
    })
    // err should be set because the event is not valid, but it is nil
    return err
}

//ftl:subscribe sub
//ftl:retry 3 5s 30s
func ProcessEvent(ctx context.Context, event Event) error {
    // never reached
    return nil
}

When Publish() is called, FTL creates the event but fails each time it tries to consume it.
So for one published event, we get all 4 attempts logged like this:

warn:sub:example.sub:example.processEvent: Async call could not be called: could not validate HTTP request body: example.Event.name is required
warn:sub:example.sub:example.processEvent: Async call could not be called: could not validate HTTP request body: example.Event.name is required
warn:sub:example.sub:example.processEvent: Async call could not be called: could not validate HTTP request body: example.Event.name is required
warn:sub:example.sub:example.processEvent: Async call could not be called: could not validate HTTP request body: example.Event.name is required
@github-actions github-actions bot added the triage Issue needs triaging label Aug 8, 2024
@ftl-robot ftl-robot mentioned this issue Aug 8, 2024
@deniseli deniseli added bug Something isn't working next Work that will be be picked up next and removed triage Issue needs triaging labels Aug 8, 2024
@jonathanj-square jonathanj-square self-assigned this Aug 13, 2024
@github-actions github-actions bot removed the next Work that will be be picked up next label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants