Skip to content

Require request ID and a completion callback when attaching callbacks on StartActivityExecution conflict#10679

Open
tekkaya wants to merge 1 commit into
mainfrom
gokhan/saa-onconflict-callbacks-require-requestid
Open

Require request ID and a completion callback when attaching callbacks on StartActivityExecution conflict#10679
tekkaya wants to merge 1 commit into
mainfrom
gokhan/saa-onconflict-callbacks-require-requestid

Conversation

@tekkaya

@tekkaya tekkaya commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What changed?

StartActivityExecution now validates on_conflict_options (chasm/lib/activity/validator.go, called from validateAndPopulateStartRequest in chasm/lib/activity/frontend.go):

  • When attach_completion_callbacks is set, the request must also set attach_request_id and include at least one completion_callbacks entry; otherwise the request fails with InvalidArgument.
  • attach_links and attach_request_id remain independently valid.

Added unit tests in chasm/lib/activity/validator_test.go (nil, request-id+callbacks+callback, links-only, request-id-only → ok; callbacks-without-request-id, callbacks-flag-without-callbacks → error).

Why?

On the USE_EXISTING conflict path, on_conflict_options can attach completion callbacks to the already-running activity. A completion callback is keyed to the request ID, but the request ID is only recorded on the existing execution when attach_request_id is set — so attaching callbacks without the request ID orphans the callback, and attach_completion_callbacks with no callbacks provided is a no-op (the handler gates on attach_completion_callbacks && len(callbacks) > 0). Per review feedback, the server should reject these invalid combinations instead of silently accepting them.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Ran go test ./chasm/lib/activity/ and the standalone-activity functional tests locally: TestStandaloneActivityTestSuite/TestStart (covers AttachLinksOnConflictUnionsLinks and the OnConflictOptions subtest) and .../TestCallbacksDisabled both pass. All CI functional tests pass.

Potential risks

  • Rejects previously-accepted (no-op) requests: callbacks-without-request-id and callbacks-flag-without-callbacks now return InvalidArgument. These did nothing useful before, but any caller relying on the silent no-op behavior would now get an error.
  • Links scope: the rule is intentionally scoped to callbacks; attach_links-only stays valid. An earlier stricter version rejected everything except {request_id + callbacks} and broke AttachLinksOnConflictUnionsLinks. If links should also be restricted, that's a follow-up that changes those existing tests.
  • Related gap (not addressed here): AttachRequestId is currently a no-op on the activity conflict path (no references to it in chasm/lib/activity/; the conflict block only attaches callbacks/links). With this validation in place, the handler should also record the request ID on the existing execution when AttachRequestId is set, mirroring the workflow path's AddWorkflowExecutionOptionsUpdatedEvent(..., requestID, completionCallbacks, ...). Can be folded in here or as a follow-up.

@CLAassistant

CLAassistant commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch from 8f8441f to 5f35af6 Compare June 12, 2026 16:57
@tekkaya tekkaya changed the title Reject standalone-activity conflict options that attach callbacks without a request ID Reject standalone-activity conflict options unless request ID and callbacks are attached together Jun 12, 2026
@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch 2 times, most recently from 98198c4 to a232e01 Compare June 12, 2026 17:22
@tekkaya tekkaya changed the title Reject standalone-activity conflict options unless request ID and callbacks are attached together Reject standalone-activity conflict options unless request ID and a completion callback are attached together Jun 12, 2026
@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch from a232e01 to 0e2fa54 Compare June 12, 2026 17:24
@tekkaya tekkaya marked this pull request as ready for review June 12, 2026 17:25
@tekkaya tekkaya requested a review from a team as a code owner June 12, 2026 17:25
@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch from 0e2fa54 to 95c8fd0 Compare June 12, 2026 17:54
@tekkaya tekkaya changed the title Reject standalone-activity conflict options unless request ID and a completion callback are attached together Require request ID and a completion callback when attaching callbacks on StartActivityExecution conflict Jun 12, 2026
@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch from 95c8fd0 to c9a8ad9 Compare June 12, 2026 19:51
Comment thread chasm/lib/activity/validator.go Outdated
// attach_links and attach_request_id remain independently valid.
func validateOnConflictOptions(req *workflowservice.StartActivityExecutionRequest) error {
onConflictOptions := req.GetOnConflictOptions()
if onConflictOptions == nil || !onConflictOptions.GetAttachCompletionCallbacks() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This condition isn't right. It's also invalid to only attach a request ID.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is attaching a requestID and links without completion callbacks a valid scenario?

@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch from c9a8ad9 to e93a551 Compare June 12, 2026 22:35
On the USE_EXISTING path, on_conflict_options must be internally consistent:
- attach_completion_callbacks requires attach_request_id (a completion callback
  is recorded against the request ID; see addCompletionCallbacks).
- attach_request_id requires at least one completion callback or link, since
  attaching a request ID is only meaningful alongside something to attach.

attach_links is independent and may be set on its own. Invalid combinations now
fail with InvalidArgument instead of being silently accepted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tekkaya tekkaya force-pushed the gokhan/saa-onconflict-callbacks-require-requestid branch from e93a551 to 38acef8 Compare June 12, 2026 23:08
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.

3 participants