Skip to content

Add defaultEventSource to WorkflowApplication#1556

Merged
fjtirado merged 1 commit into
open-workflow-specification:mainfrom
matheusandre1:issue1554
Jul 24, 2026
Merged

Add defaultEventSource to WorkflowApplication#1556
fjtirado merged 1 commit into
open-workflow-specification:mainfrom
matheusandre1:issue1554

Conversation

@matheusandre1

Copy link
Copy Markdown
Contributor

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it: Closes: #1554

Special notes for reviewers:

Additional information (if needed):

@matheusandre1
matheusandre1 marked this pull request as ready for review July 22, 2026 18:32
@matheusandre1
matheusandre1 requested a review from fjtirado as a code owner July 22, 2026 18:32
@ricardozanini

Copy link
Copy Markdown
Collaborator

@matheusandre1 you must sign your commits with -S.

@matheusandre1

Copy link
Copy Markdown
Contributor Author

@matheusandre1 you must sign your commits with -S.

Sorry, I always forget about that.

@fjtirado fjtirado left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matheusandre1
Lets make default event source a WorkflowValueResolver, so it returns an URI from the WorkflowContext, TaskContext and Model

@matheusandre1
matheusandre1 force-pushed the issue1554 branch 2 times, most recently from bd2d409 to 37dd274 Compare July 23, 2026 05:39
Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/events/EmitSourceResolver.java Outdated
Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java Outdated
Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java Outdated
Comment thread impl/test/src/test/java/io/serverlessworkflow/impl/test/EmitExecutorTest.java Outdated
Comment thread impl/test/src/test/java/io/serverlessworkflow/impl/test/EmitExecutorTest.java Outdated
Comment thread impl/test/src/test/java/io/serverlessworkflow/impl/test/EmitExecutorTest.java Outdated
Comment thread impl/test/src/test/java/io/serverlessworkflow/impl/test/EmitExecutorTest.java Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves CloudEvent emission defaults by introducing an application-level default source resolver and by ensuring emitted events always have a time value, aligning emitted events more closely with the Serverless Workflow spec requirements discussed in #1554.

Changes:

  • Added defaultEventSource to WorkflowApplication (configurable via builder, with a sensible default resolver).
  • Updated EmitExecutor to default source via the application’s resolver and to always set time (defaulting to OffsetDateTime.now()).
  • Added test coverage (including a YAML-based workflow sample) verifying defaulting and precedence behavior for source, time, and id.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
impl/test/src/test/resources/workflows-samples/emit-default-source.yaml Adds a YAML workflow sample used to verify default CloudEvent source behavior when loading workflows from YAML.
impl/test/src/test/java/io/serverlessworkflow/impl/test/EmitExecutorTest.java Adds tests covering source defaulting/override precedence, and time/id defaults for emitted events.
impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java Introduces defaultEventSource on the application and builder APIs to configure it, with a default resolver.
impl/core/src/main/java/io/serverlessworkflow/impl/executors/EmitExecutor.java Switches emitted event source defaulting to use WorkflowApplication.defaultEventSource() and defaults time to now.
impl/core/src/main/java/io/serverlessworkflow/impl/events/EmitSourceResolver.java Adds the default resolver implementation that builds source from application id + workflow definition id.
impl/core/src/main/java/io/serverlessworkflow/impl/events/CloudEventUtils.java Updates the static fallback source() URI value to a more meaningful identifier.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings July 23, 2026 22:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

@ricardozanini

Copy link
Copy Markdown
Collaborator

@matheusandre1 when generating the source URI please add the prefix /. E.g. /org-acme/payment-processor/1.0.0

Copilot AI review requested due to automatic review settings July 23, 2026 23:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread impl/core/src/main/java/io/serverlessworkflow/impl/events/EmitSourceResolver.java Outdated
Signed-off-by: Matheus André <matheusandr2@gmail.com>
Copilot AI review requested due to automatic review settings July 24, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowApplication.java:413

  • withDefaultEventSource(URI) accepts null and wraps it into a resolver that returns null. That prevents the default EmitSourceResolver fallback from being applied and will later pass null into CloudEventBuilder.withSource(...) (likely causing a runtime NPE/IAE during emit). Fail fast by rejecting null here.
    public Builder withDefaultEventSource(URI defaultEventSource) {
      return withDefaultEventSource((workflow, task, model) -> defaultEventSource);
    }

impl/core/src/main/java/io/serverlessworkflow/impl/executors/EmitExecutor.java:109

  • defaultEventSource().apply(...) is used directly as the CloudEvent source. If a custom resolver returns null (or a caller previously passed a null URI), this will propagate into ceBuilder.withSource(...) and fail at runtime with an opaque NPE. Enforce a non-null resolved source with a clear message.
                    workflow
                        .definition()
                        .application()
                        .defaultEventSource()
                        .apply(workflow, taskContext, taskContext.input())));

@fjtirado
fjtirado merged commit a0dac91 into open-workflow-specification:main Jul 24, 2026
3 checks passed
@matheusandre1
matheusandre1 deleted the issue1554 branch July 24, 2026 18:58
@ricardozanini

Copy link
Copy Markdown
Collaborator

@matheusandre1 wanna open the counterpart in quarkus-flow? quarkiverse/quarkus-flow#776 We can use the defaultSource from here.

@matheusandre1

Copy link
Copy Markdown
Contributor Author

@matheusandre1 wanna open the counterpart in quarkus-flow? quarkiverse/quarkus-flow#776 We can use the defaultSource from here.

I would, actually, but there are two open pull requests mentioning the issue.

@matheusandre1

Copy link
Copy Markdown
Contributor Author

The GitHub PR is down; I'll submit the pull request when the next SDK release comes out.
cc: @ricardozanini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve CloudEvent defaults and validation for emit events

4 participants