Skip to content

Return clear error for unsupported interceptor kind in sink - #2096

Open
pujitha24 wants to merge 3 commits into
tektoncd:mainfrom
pujitha24:auto/issue-1772
Open

Return clear error for unsupported interceptor kind in sink#2096
pujitha24 wants to merge 3 commits into
tektoncd:mainfrom
pujitha24:auto/issue-1772

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Changes

Fixes a confusing error surfaced by the eventlistener sink when a TriggerInterceptor's Ref.Kind is neither ClusterInterceptor nor NamespacedInterceptor (for example, when a Trigger is created before the admission webhook has defaulted the interceptor kind, as seen in ArgoCD-managed clusters). Previously, Sink.ExecuteInterceptors left the local url variable nil in this case and passed it straight to interceptors.Execute, resulting in the sink POSTing to an empty URL and surfacing Go's raw transport error Post "": unsupported protocol scheme "" instead of a message identifying the actual problem.

This adds the missing else branch alongside the existing Kind checks in ExecuteInterceptors (pkg/sink/sink.go) so an unrecognized/unset Ref.Kind returns a clear, immediate error naming the offending interceptor kind and name, and fails fast rather than after an HTTP round-trip attempt. This does not change the outcome for the request (the interceptor still cannot run and the trigger still will not fire either way) — it only replaces the cryptic low-level HTTP error with an actionable one.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

The eventlistener sink now returns a clear error when a TriggerInterceptor has an unsupported or unset Ref.Kind, instead of a cryptic `Post "": unsupported protocol scheme ""` error.

AI assistance: this change was drafted with Claude Code.

Fixes #1772

Motivation:
Users report the eventlistener sink logging the confusing error
`Post "": unsupported protocol scheme ""` while processing trigger
interceptors, notably in clusters (e.g. ArgoCD-managed) where a Trigger
can be created before the admission webhook has defaulted its
interceptor kind. When a TriggerInterceptor's Ref.Kind is neither
ClusterInterceptor nor NamespacedInterceptor, Sink.ExecuteInterceptors
left its local `url` variable nil and passed it straight to
interceptors.Execute. apis.URL.String() nil-checks and returns "",
so the sink ends up POSTing to an empty URL and surfaces Go's raw
transport error instead of a message that identifies the actual
problem.

Approach:
Add the missing else branch alongside the existing Kind checks in
ExecuteInterceptors (pkg/sink/sink.go) so an unrecognized/unset
Ref.Kind returns a clear, immediate error naming the offending
interceptor kind and name, instead of silently falling through to a
nil URL. This does not change what happens to the request (the
interceptor still cannot run and the trigger still will not fire
either way) - it only replaces a cryptic low-level HTTP error with an
actionable one and fails fast rather than after an HTTP round-trip
attempt.

Validation:
- go build ./...
- go vet ./pkg/sink/...
- gofmt -l pkg/sink/sink.go pkg/sink/sink_test.go (no output)
- make test-unit (go test ./...) passes across the full repo,
  including the new pkg/sink/sink_test.go:TestExecuteInterceptor_UnsupportedKind
- Reproduced the exact reported error: temporarily reverted the
  sink.go change (keeping only the new test) and confirmed the test
  observes `Post "": unsupported protocol scheme ""`, byte-for-byte
  matching the error in the issue. Restored the fix and confirmed the
  same test now observes the new clear error message instead.

Report: tektoncd#1772
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 9, 2026
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 9, 2026
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.08%. Comparing base (d079e1f) to head (7193b54).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2096       +/-   ##
===========================================
+ Coverage   32.14%   80.08%   +47.94%     
===========================================
  Files         260       93      -167     
  Lines       11967     4510     -7457     
===========================================
- Hits         3847     3612      -235     
+ Misses       7797      651     -7146     
+ Partials      323      247       -76     
Flag Coverage Δ
unit-tests 80.08% <ø> (+47.94%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

golangci-lint's dogsled linter flagged the 3-blank-identifier
declaration added by this PR's new test. Name the []byte return
value and include it in the failure message, consistent with the
pattern already used elsewhere in this test file.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@pujitha24

Copy link
Copy Markdown
Contributor Author

/assign @savitaashture

Comment thread pkg/sink/sink_test.go
resp, _, _, err := s.ExecuteTriggerInterceptors(trigger, &http.Request{URL: url}, json.RawMessage(`{"head": "blah"}`), s.Logger, "eventID", map[string]interface{}{})
if err == nil {
t.Fatalf("ExecuteInterceptor() expected an error for an unsupported interceptor kind, got none: %+v", resp)
}

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.

Can we also assert that the error message contains "unsupported interceptor kind"?

Per review feedback, also verify the returned error names the unsupported
interceptor kind rather than just checking that an error occurred.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@pujitha24

Copy link
Copy Markdown
Contributor Author

Good catch, added — the test now also asserts err.Error() contains "unsupported interceptor kind".

@khrm khrm 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.

/approve

@savitaashture Let's review and merge this.

@tekton-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: khrm

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EventListener Unsupported Protocol Scheme Error

4 participants