Skip to content

Commit e229c3f

Browse files
committed
forward relay metadata for remote capability execution
(cherry picked from commit 16e4fc9)
1 parent 3f9f9b8 commit e229c3f

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

core/capabilities/confidentialrelay/handler.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,20 @@ func (h *Handler) handleCapabilityExecute(ctx context.Context, gatewayID string,
354354
return h.errorResponse(ctx, gatewayID, req, jsonrpc.ErrInvalidParams, fmt.Errorf("failed to unmarshal capability request: %w", err))
355355
}
356356

357+
referenceID := params.ReferenceID
358+
if referenceID == "" {
359+
referenceID = req.ID
360+
}
361+
357362
capReq := capabilities.CapabilityRequest{
358363
Payload: sdkReq.Payload,
359364
Method: sdkReq.Method,
360365
CapabilityId: params.CapabilityID,
361366
Metadata: capabilities.RequestMetadata{
362-
WorkflowID: params.WorkflowID,
367+
WorkflowID: params.WorkflowID,
368+
WorkflowOwner: params.Owner,
369+
WorkflowExecutionID: params.ExecutionID,
370+
ReferenceID: referenceID,
363371
},
364372
}
365373

core/capabilities/confidentialrelay/handler_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ func TestHandler_HandleGatewayMessage(t *testing.T) {
182182
req: func(t *testing.T) *jsonrpc.Request[json.RawMessage] {
183183
return makeRequest(t, confidentialrelaytypes.MethodCapabilityExec, confidentialrelaytypes.CapabilityRequestParams{
184184
WorkflowID: "wf-1",
185+
Owner: "0xowner",
186+
ExecutionID: "32c631d295ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce1",
187+
ReferenceID: "17",
185188
CapabilityID: "my-cap@1.0.0",
186189
Payload: makeCapabilityPayload(t, map[string]any{"key": "val"}),
187190
Attestation: testAttestationB64,
@@ -199,6 +202,14 @@ func TestHandler_HandleGatewayMessage(t *testing.T) {
199202
assert.Equal(t, "result-proto-bytes", string(capResp.GetPayload().GetValue()))
200203
assert.Empty(t, result.Error)
201204
},
205+
checkExecutable: func(t *testing.T, reg *mockCapRegistry) {
206+
exec := reg.executables["my-cap@1.0.0"]
207+
require.NotNil(t, exec.lastRequest, "Execute should have been called")
208+
assert.Equal(t, "wf-1", exec.lastRequest.Metadata.WorkflowID)
209+
assert.Equal(t, "0xowner", exec.lastRequest.Metadata.WorkflowOwner)
210+
assert.Equal(t, "32c631d295ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce1", exec.lastRequest.Metadata.WorkflowExecutionID)
211+
assert.Equal(t, "17", exec.lastRequest.Metadata.ReferenceID)
212+
},
202213
},
203214
{
204215
name: "capability execute sets Inputs from Payload for backward compat",

0 commit comments

Comments
 (0)