-
Notifications
You must be signed in to change notification settings - Fork 25
trigger wrapper generator changes to support capability errors #1755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request updates the trigger wrapper generator to support capability errors by replacing standard error returns with caperrors.Error in trigger registration and unregistration methods.
Key Changes
- Updated trigger interface method signatures to return
caperrors.Errorinstead oferror - Added adapter functions to bridge between the new capability error interface and the existing
RegisterTriggerimplementation - Regenerated code with protoc-gen-go v1.36.10
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/capabilities/v2/triggers/cron/trigger.pb.go | Updated protoc-gen-go version from v1.36.8 to v1.36.10 |
| pkg/capabilities/v2/triggers/cron/server/trigger_server_gen.go | Changed trigger method return types to caperrors.Error and added adapter functions for RegisterTrigger calls |
| pkg/capabilities/v2/protoc/pkg/templates/server.go.tmpl | Updated template to generate trigger methods with caperrors.Error return types and adapter function wrappers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
👋 ettec, 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! |
|
19be6d3 to
5a67a22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.
| Benchmark suite | Current: 110438b | Previous: 19be6d3 | Ratio |
|---|---|---|---|
BenchmarkKeystore_Sign/nop/in-process |
791.5 ns/op |
376.7 ns/op |
2.10 |
This comment was automatically generated by workflow using github-action-benchmark.
| case {{- if (MapToUntypedAPI .) }} "" {{- else}} "{{.GoName}}" {{- end }}: | ||
| input := &{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}{} | ||
| return capabilities.RegisterTrigger(ctx, c.stopCh, {{$fullCapabilityId}}, request, input, c.{{$service.GoName}}Capability.Register{{.GoName}}) | ||
| return capabilities.RegisterTrigger(ctx, c.stopCh, {{$fullCapabilityId}}, request, input, func(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) (<-chan capabilities.TriggerAndId[*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}], error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you making this change? It looks like you are adding a function that just makes the underlying call and nothing else. Is it some problem with error subtypes..? Please explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a simpler way to do this - I've updated utils.go instead.
376a08e to
a521461
Compare
1a0c00b to
0f8f29e
Compare
| Register{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) (<- chan capabilities.TriggerAndId[*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}], error) | ||
| Unregister{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) error | ||
| Register{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) (<- chan capabilities.TriggerAndId[*{{ImportAlias .Output.GoIdent.GoImportPath}}.{{.Output.GoIdent.GoName}}], caperrors.Error) | ||
| Unregister{{.GoName}}(ctx context.Context, triggerID string, metadata capabilities.RequestMetadata, input *{{ImportAlias .Input.GoIdent.GoImportPath}}.{{.Input.GoIdent.GoName}}) caperrors.Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
despite I like bubbling up errors to the user, even when doing an unregistration, I'm failing to see how this will actually work in our current UX.
The unregistration event could happen either bc a customer pauses or deletes a WF, where are the errors going to show up if it pauses it? and if it's deleted are we planning in showing them the errors too?
Having said that, from EVM log trigger perspective: there's no way an unregistration is caused by user error, as if it was registered then it means all inputs are green, therefore any further error is just internal. So I'd rather leave this as error or even forcing it to be SystemError (which I believe is not possible currently, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, I can't see any use case for the user/system origin and visibility attributes of caperrors on unregistration errors right now, but for consistency with all other capability APIs and to allow for some future unforeseen case it seems to make sense to also migrate it - but I could be persuaded otherwise.
pushing changes done so far to support trigger capability errors