Skip to content

[Backport release-1.12] Fix(cuex): send vela/http request headers as the template declares them - #7621

Closed
briankane wants to merge 2 commits into
kubevela:release-1.12from
briankane:backport/http-request-headers-1.12
Closed

briankane wants to merge 2 commits into
kubevela:release-1.12from
briankane:backport/http-request-headers-1.12

Conversation

@briankane

@briankane briankane commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Description of your changes

Backport to release-1.12 of #7596: vela/http in component, trait, policy and source templates can send request headers again. The template declares one string per name, but the request decoded headers as http.Header (a list per name), so any call setting a header failed at render with cannot unmarshal string into Go struct field DoParams.$params.request.header... of type []string.

The same two commits as #7596:

  1. Fix(cuex): send vela/http request headers as the template declares them. guardedhttp reads the request with params of its own, one string per name.
  2. Chore(cuex): take vela/http request building from kubevela/pkg. Bumps kubevela/pkg to ff99f28 (Fix(cuex): send vela/http request headers as the template declares them pkg#157), the same pin as master, and guardedhttp builds its request with kvhttp.NewRequest. Headers are added with Header.Add, so names differing only in case each reach the request. The bump also brings Fix(cel): bound an expression's evaluation by cost and by its caller's context pkg#156 (CEL evaluation bounded by cost and by its caller's context), as on master.

Issue: #7595

I have:

  • All commits are signed off (DCO).

How has this code been tested

The guardedhttp specs render templates through the real compiler against a local HTTP server: two request headers both arrive, and X-Tag/x-tag both arrive. Each fails on release-1.12 without its fix. go build ./... and go test ./pkg/cue/... pass with no workspace file.

View guided diff

vela/http's template declares request headers and trailers as one string
per name, but guardedhttp decoded them into the upstream RequestVars, which
takes http.Header, a list per name. CUE refuses a list and the decoder
refuses a string, so a component, trait, policy or source template could set
no request header at all: the call failed with "cannot unmarshal string into
Go struct field DoParams.$params.request.header.X-Token of type []string".

guardedhttp now reads the request with its own params type, one string per
name, and builds the http.Header. This matches the vela/http workflow
provider, which has always taken headers this way, and does not wait on a
kubevela/pkg bump, so it backports to every release line that has
guardedhttp.

Signed-off-by: Brian Kane <briankane1@gmail.com>
(cherry picked from commit 829a2a3)
Bump kubevela/pkg to ff99f28 (kubevela/pkg#157), which reads request headers and trailers as one
string per name and exports NewRequest. guardedhttp drops its own request
types and builds the request with NewRequest, keeping only its own client
and response read.

Headers are now added with Header.Add, so names that differ only in case
(X-Tag, x-tag) each reach the request.

Signed-off-by: Brian Kane <briankane1@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 4 files

View guided diff | Re-trigger cubic

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.91%. Comparing base (30ad613) to head (345712d).
⚠️ Report is 12 commits behind head on release-1.12.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-1.12    #7621      +/-   ##
================================================
+ Coverage         81.20%   81.91%   +0.70%     
================================================
  Files               496      524      +28     
  Lines             52884    57537    +4653     
================================================
+ Hits              42944    47130    +4186     
- Misses             9937    10403     +466     
- Partials              3        4       +1     
Flag Coverage Δ
core-unittests 81.91% <100.00%> (+0.70%) ⬆️

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.

@briankane

Copy link
Copy Markdown
Member Author

Folded into #7591 (squashed with the kubevela/pkg bump), closing in favour of it.

@briankane briankane closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant