feat(wasm/host): set capability_id on error responses#1934
feat(wasm/host): set capability_id on error responses#1934
Conversation
Populate the new CapabilityResponse.capability_id field when a capability call returns an error. This allows the workflow engine to attribute execution failures to the specific capability that caused them. Depends on: smartcontractkit/chainlink-protos#332
|
👋 vreff, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
📊 API Diff Results
|
There was a problem hiding this comment.
Pull request overview
This PR ensures capability error responses generated by the WASM host preserve the originating capability ID, enabling downstream workflow-engine metrics (e.g., platform_engine_workflow_execution_failed_count) to attribute failures to specific capabilities.
Changes:
- Populate
CapabilityResponse.capability_idwhenCallCapabilityreturns an error incallCapAsync. - Bump
github.com/smartcontractkit/chainlink-protos/cre/goto a revision that includes the new proto field.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/workflows/wasm/host/execution.go | Adds CapabilityId: req.Id to host-generated error CapabilityResponses. |
| go.mod | Updates chainlink-protos/cre/go dependency to a newer pseudo-version. |
| go.sum | Updates checksums for the bumped chainlink-protos/cre/go version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| resp = &sdkpb.CapabilityResponse{ | ||
| Response: &sdkpb.CapabilityResponse_Error{ | ||
| Error: err.Error(), | ||
| }, | ||
| CapabilityId: req.Id, |
There was a problem hiding this comment.
New behavior (wrapping CallCapability errors into a CapabilityResponse and setting CapabilityId) isn’t covered by existing tests. Please add a unit test that mocks ExecutionHelper.CallCapability to return a non-nil err and asserts the awaited response contains Response_Error and CapabilityId == req.Id.
Summary
Set
CapabilityResponse.capability_idwhen a capability call returns an error in the WASM host.Motivation
The workflow engine needs to attribute execution failures to specific capabilities in the
platform_engine_workflow_execution_failed_countOTel metric. The capability ID is lost when errors cross the WASM boundary becauseCapabilityResponse_Errorwas previously just a string. With the newcapability_idfield added to the proto (smartcontractkit/chainlink-protos#332), the host can now tag error responses.Changes
pkg/workflows/wasm/host/execution.go: SetCapabilityId: req.Idon error responses incallCapAsyncgo.mod/go.sum: Bumpchainlink-protos/cre/goto include the new fieldDepends on