Skip to content

[SDK Ergonomics] NEXUS-519: Support Query-backed Nexus Operations - #11274

Merged
mavemuri merged 3 commits into
mainfrom
mavemuri/nexus-query
Aug 20, 2026
Merged

[SDK Ergonomics] NEXUS-519: Support Query-backed Nexus Operations#11274
mavemuri merged 3 commits into
mainfrom
mavemuri/nexus-query

Conversation

@mavemuri

@mavemuri mavemuri commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What changed?

Adds server support for WorkflowQuery-backed Nexus Operations

Why?

Part of effort to expose all Temporal primitives as Nexus Operations

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)

TODO:

@mavemuri mavemuri added the request-claude-review Request Claude review for this PR label Jul 24, 2026
Comment thread go.mod Outdated
Comment thread service/history/api/queryworkflow/api.go
Comment thread common/nexus/links.go
Comment thread tests/query_workflow_test.go Outdated
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch 3 times, most recently from c6bd436 to d0784fb Compare July 25, 2026 00:11
Comment thread go.mod Outdated
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch 4 times, most recently from 52ae6e5 to 2657210 Compare July 25, 2026 01:07
@mavemuri
mavemuri marked this pull request as ready for review July 27, 2026 16:02
@mavemuri
mavemuri requested review from a team as code owners July 27, 2026 16:02
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Claude finished @mavemuri's task in 7m 1s —— View job


Review complete

  • Read review skill + .github/copilot-instructions.md
  • Analyzed the diff (common/nexus/links.go, service/history/api/queryworkflow/api.go, tests/query_workflow_test.go, go.mod/go.sum, matching test import)
  • Traced the link through the frontend passthrough (workflow_handler.go:3282), common/links.Validate, and the ConvertNexusLinksToProtoLinks callers
  • Posted 5 inline comments

Overall the change looks sound: the resp.GetResponse() == nil guard makes the deferred block safe on every return path, the defer is registered after the early error returns so only real responses get a link, and the functional test covers both the "Query processed" (direct-through-matching) and "Query rejected" (early-return) branches. Findings are inline — the one worth a real decision is that common/links.Validate rejects the Link_Workflow variant, so the link this PR returns can't be attached to a follow-up request.
Branch: mavemuri/nexus-query

Comment thread service/history/api/queryworkflow/api.go Outdated
Comment thread service/history/api/queryworkflow/api.go
Comment thread common/nexus/links.go
Comment thread go.mod Outdated
Comment thread service/matching/task_queue_partition_manager_test.go
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from 2657210 to ad84e98 Compare July 27, 2026 19:02
@mavemuri mavemuri added request-claude-review Request Claude review for this PR and removed request-claude-review Request Claude review for this PR labels Jul 27, 2026
Comment thread go.mod Outdated
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch 3 times, most recently from 7c59a1e to 203efe9 Compare July 31, 2026 17:10
@mavemuri mavemuri added request-claude-review Request Claude review for this PR and removed request-claude-review Request Claude review for this PR labels Jul 31, 2026
Comment thread service/history/api/queryworkflow/api.go
Comment thread common/nexus/links.go
Comment thread tests/query_workflow_test.go Outdated

@long-nt-tran long-nt-tran 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.

I think we definitely need a couple Nexus-based query test here as well. Off the top of my head, I think we should at least test:

  1. Ongoing workflow, well-formed query (happy path)
  2. Ongoing workflow, malformed query (correct error returned)
  3. Completed workflow, well-formed query (and under different QueryRejectCondition states)
  4. Completed workflow, malformed query (and under different QueryRejectCondition states)

When I did linking for signals I put that under tests/nexus_workflow_test.go, but feel free to make a new tests/nexus_query_test.go instead of piling on.


For example, here's how we'd set up such a Nexus-based test -- I'm using a Nexus signal test as a reference:

  1. Map the handler (on the callee side) to a query (example with signal)
  2. Map the Nexus op (on the callee side) to a query (example with signal)
  3. Have a caller workflow invoke the Nexus operation (example with signal)
  4. In my test I validated that the signal shows up in history, but for query I think you can validate that the query successfully returns, or some validation that indicates the expected success/failure outcome(s)

Comment thread tests/query_workflow_test.go
@mavemuri

mavemuri commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

I think we definitely need a couple Nexus-based query test here as well. Off the top of my head, I think we should at least test:

  1. Ongoing workflow, well-formed query (happy path)
  2. Ongoing workflow, malformed query (correct error returned)
  3. Completed workflow, well-formed query (and under different QueryRejectCondition states)
  4. Completed workflow, malformed query (and under different QueryRejectCondition states)

When I did linking for signals I put that under tests/nexus_workflow_test.go, but feel free to make a new tests/nexus_query_test.go instead of piling on.

For example, here's how we'd set up such a Nexus-based test -- I'm using a Nexus signal test as a reference:

  1. Map the handler (on the callee side) to a query (example with signal)
  2. Map the Nexus op (on the callee side) to a query (example with signal)
  3. Have a caller workflow invoke the Nexus operation (example with signal)
  4. In my test I validated that the signal shows up in history, but for query I think you can validate that the query successfully returns, or some validation that indicates the expected success/failure outcome(s)

Agree, had added more cases in the sdk-go PR temporalio/sdk-go#2508
Will add here as well

@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from 203efe9 to f559856 Compare August 19, 2026 03:59
@mavemuri
mavemuri requested a review from a team August 19, 2026 03:59
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from f559856 to 84ffca9 Compare August 19, 2026 04:34
@mavemuri
mavemuri requested a review from long-nt-tran August 19, 2026 05:03

@long-nt-tran long-nt-tran 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.

Thanks for adding more tests!

Comment thread tests/query_workflow_test.go Outdated
Comment thread tests/query_workflow_test.go Outdated
name: "well-formed replayable query succeeds",
query: &querypb.WorkflowQuery{QueryType: queryName},
reason: "Query processed",
result: "failed",

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.

nit: maybe send a different value to the signal handler rather than "failed" :D (i.e., "completed") I was slightly confused at first glance why "failed" meant success here

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.

Ah sure! just wanted to convey that this is something that the completed workflow handler would return(to not confuse with "state" of workflow etc), maybe "processed" instead? will fix

@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from 84ffca9 to 46344cb Compare August 19, 2026 20:45
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from 46344cb to 064ae72 Compare August 20, 2026 21:14
@mavemuri
mavemuri merged commit 0425053 into main Aug 20, 2026
54 checks passed
@mavemuri
mavemuri deleted the mavemuri/nexus-query branch August 20, 2026 22:43
davidporter-id-au pushed a commit to davidporter-id-au/temporal that referenced this pull request Aug 24, 2026
…mporalio#11274)

## What changed?
Adds server support for WorkflowQuery-backed Nexus Operations 

## Why?
Part of effort to expose all Temporal primitives as Nexus Operations 

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [x] added new functional test(s)

## TODO:
- [x] temporalio/api#842
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request-claude-review Request Claude review for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants