Skip to content

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

Open
mavemuri wants to merge 2 commits into
mainfrom
mavemuri/nexus-query
Open

[SDK Ergonomics] NEXUS-519: Support Query-backed Nexus Operations#11274
mavemuri wants to merge 2 commits into
mainfrom
mavemuri/nexus-query

Conversation

@mavemuri

@mavemuri mavemuri commented Jul 24, 2026

Copy link
Copy Markdown

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
go.opentelemetry.io/otel/sdk/metric v1.43.0
go.opentelemetry.io/otel/trace v1.44.0
go.temporal.io/api v1.63.4
go.temporal.io/api v1.62.15-0.20260622232249-060670b1b866

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

placeholder until api change is merged

@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
// Note: QueryWorkflow should not alter mutable state, so it is safe to ignore error and not clear ms.
workflowLease.GetReleaseFn()(nil)
}()
defer func() {

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.

common/links.Validate has no *commonpb.Link_Workflow_ case — it falls into default: and returns InvalidArgument: "unsupported link variant" (common/links/validator.go:60-61).

That makes the link this PR returns a dead end for the main thing links are for: taking a link you got back and attaching it to a follow-up request. A client that does

qResp, _ := c.WorkflowService().QueryWorkflow(ctx, ...)
c.WorkflowService().StartWorkflowExecution(ctx, &workflowservice.StartWorkflowExecutionRequest{
    ..., Links: []*commonpb.Link{qResp.GetLink()},
})

gets InvalidArgument: unsupported link variant. Same for SignalWorkflowExecution, SignalWithStart, and UpdateWorkflowExecution (service/frontend/workflow_handler.go:693, 2241, 2286, 2350, 2445) plus the CHASM validators (chasm/lib/workflow/validator.go:220, chasm/lib/activity/link_validator.go:34).

Strictly this gap predates the PR — updateworkflow already emits Link_Workflow for rejected updates — but this change makes the variant reachable from every query response, so it's worth closing here. Adding the case alongside the Link_Activity_ one is a few lines:

case *commonpb.Link_Workflow_:
	if t.Workflow.GetNamespace() == "" {
		return serviceerror.NewInvalidArgument("workflow link must not have an empty namespace field")
	}
	if t.Workflow.GetWorkflowId() == "" {
		return serviceerror.NewInvalidArgument("workflow link must not have an empty workflow ID field")
	}
	if t.Workflow.GetRunId() == "" {
		return serviceerror.NewInvalidArgument("workflow link must not have an empty run ID field")
	}

Comment thread common/nexus/links.go
Comment thread go.mod Outdated
go.opentelemetry.io/otel/sdk/metric v1.43.0
go.opentelemetry.io/otel/trace v1.44.0
go.temporal.io/api v1.63.4
go.temporal.io/api v1.62.15-0.20260622232249-060670b1b866

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.

Beyond the replace placeholder you already flagged below: this line also downgrades the require from v1.63.4 (which main just moved to in #11264) to the older v1.62.15-0.20260622232249-060670b1b866 pseudo-version. The replace masks that today, so it's easy to miss — but if the replace is dropped without also restoring the require, the module silently regresses to a pre-v1.63.4 API.

When temporalio/api#842 lands, the cleanup is: delete the replace, set this back to the released tag (>= v1.63.4), and restore the two go.temporal.io/api lines that were removed from go.sum.

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
Comment thread service/history/api/queryworkflow/api.go Outdated
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from a672bd2 to a823805 Compare July 30, 2026 00:41
@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 30, 2026
Comment thread go.mod Outdated
Comment thread service/history/api/queryworkflow/api.go
Comment thread service/history/api/queryworkflow/api.go
mavemuri added a commit to temporalio/api that referenced this pull request Jul 30, 2026
For Nexus Operations. Query is both read-only and sync- so
1. no callbacks
2. the link is only from caller to the handler- and is specifically a
workflow link as there isnt a history event in handler for query

<!-- Describe what has changed in this PR -->
**What changed?**
Added link field to QueryWorkflowResponse

<!-- Tell your future self why have you made these changes -->
**Why?**
Required for QueryWorkflow-backed Nexus Operations

<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**
None

<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
**Server PR**
temporalio/temporal#11274 (Note: no server
breakage)
temporal-cicd Bot pushed a commit to temporalio/api-go that referenced this pull request Jul 30, 2026
For Nexus Operations. Query is both read-only and sync- so
1. no callbacks
2. the link is only from caller to the handler- and is specifically a
workflow link as there isnt a history event in handler for query

<!-- Describe what has changed in this PR -->
**What changed?**
Added link field to QueryWorkflowResponse

<!-- Tell your future self why have you made these changes -->
**Why?**
Required for QueryWorkflow-backed Nexus Operations

<!-- Are there any breaking changes on binary or code level? -->
**Breaking changes**
None

<!-- If this breaks the Server, please provide the Server PR to merge
right after this PR was merged. -->
**Server PR**
temporalio/temporal#11274 (Note: no server
breakage)
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch 2 times, most recently from b4aff7c to 2e97eb4 Compare July 30, 2026 23:17
@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 30, 2026
Comment thread common/nexus/links.go
Comment thread tests/query_workflow_test.go
Comment thread service/history/api/queryworkflow/api.go
Comment thread go.mod Outdated
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch from 66ea079 to 7c59a1e Compare July 31, 2026 17:10
@mavemuri
mavemuri force-pushed the mavemuri/nexus-query branch 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
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.

2 participants