Skip to content

added get_cookie() and get_cookie_i() template functions to rustformation#14385

Merged
davidjumani merged 3 commits into
kgateway-dev:mainfrom
andy-fong:af-rustformation-get-cookie
Jul 11, 2026
Merged

added get_cookie() and get_cookie_i() template functions to rustformation#14385
davidjumani merged 3 commits into
kgateway-dev:mainfrom
andy-fong:af-rustformation-get-cookie

Conversation

@andy-fong

Copy link
Copy Markdown
Contributor

Description

Added first class support to get cookie values from client requests for transformation

Change Type

/kind feature

Changelog

added get cookie functions to transformation template funcion

Copilot AI review requested due to automatic review settings July 10, 2026 19:03
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note labels Jul 10, 2026

Copilot AI 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.

Pull request overview

This PR extends the Rust-based transformation (rustformation/minijinja) pipeline to support reading cookie values from the incoming request via new template functions, and updates the underlying header representation to preserve multi-value headers.

Changes:

  • Added get_cookie() (case-sensitive) and get_cookie_i() (case-insensitive) template functions, with per-transform feature flags to pre-parse cookies once per request.
  • Switched Envoy header materialization from HashMap<String, String> to HashMap<String, Vec<String>> to preserve repeated headers, and added cookie parsing helpers in envoy-helpers.
  • Added new E2E transformation manifests and suite test cases covering cookie extraction behavior.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/e2e/features/transformation/testdata/transform-for-get-cookie.yaml Adds E2E manifest exercising get_cookie() with case-sensitive cookie lookups and missing-cookie behavior.
test/e2e/features/transformation/testdata/transform-for-get-cookie-i.yaml Adds E2E manifest exercising get_cookie_i() case-insensitive cookie lookups and missing-cookie behavior.
test/e2e/features/transformation/suite.go Registers new manifests and adds E2E assertions for cookie-derived headers.
internal/envoy_modules/lib/transformation/src/jinja.rs Implements get_cookie() / get_cookie_i(), adds transform-level flags, and wires cookie maps into the minijinja state.
internal/envoy_modules/lib/transformation/Cargo.toml Adds envoy-helpers dependency for shared HTTP/header/cookie utilities.
internal/envoy_modules/lib/envoy-helpers/src/http.rs Preserves multi-value headers, adds get_header, and introduces cookie parsing helpers.
internal/envoy_modules/lib/envoy-helpers/src/http/tests.rs Adds unit tests for cookie parsing and multi-value header collection.
internal/envoy_modules/filters/rustformation/src/lib.rs Threads the new header map type and transform flags through the Envoy filter.
internal/envoy_modules/Cargo.lock Updates lockfile for the new crate dependency.

Comment on lines +101 to +110
for cookie_str in cookie_values {
for (name, value) in parse_cookie_string(cookie_str) {
if let Some(ref mut m) = insensitive_m {
m.entry(name.to_lowercase()).or_insert_with(|| value.clone());
}
if let Some(ref mut m) = exact_m {
m.entry(name).or_insert(value);
}
}
}
Comment on lines +188 to +190

#[test]
fn test_parse_cookie_maps_both_none_when_neither_needed() {
Signed-off-by: Andy Fong <[email protected]>
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 10, 2026
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 10, 2026
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 10, 2026
@davidjumani
davidjumani added this pull request to the merge queue Jul 10, 2026
@davidjumani
davidjumani removed this pull request from the merge queue due to a manual request Jul 10, 2026
@davidjumani
davidjumani added this pull request to the merge queue Jul 11, 2026
Merged via the queue into kgateway-dev:main with commit 0f8f332 Jul 11, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants