Skip to content

SubstitutionFormatUtils can log multiple occurrences of same header - #46688

Merged
yanavlasov merged 9 commits into
envoyproxy:mainfrom
akamathdev:log_multi_headers
Dec 3, 2026
Merged

yanavlasov merged 9 commits into
envoyproxy:mainfrom
akamathdev:log_multi_headers

Conversation

@akamathdev

@akamathdev akamathdev commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Commit Message: SubstitutionFormatUtils can log multiple occurrences of same header

Additional Description:
Existing format specifiers will only emit the first occurrence of a header. Introduce new format specifiers (REQ_MULTI, REQUEST_HEADER_MULTI, RESP_MULTI, RESPONSE_HEADER_MULTI) that allow to print all occurrences of a given header both in the request and response.

Risk Level: Low
Testing:
Manual testing done locally. Added tests that cover the new substitution commands.

Docs Changes: Updated substitution formatter docs to add the new commands that this PR adds.
Release Notes: Added a file to the changelogs directory with a summary.
Platform Specific Features:

Attempt at #13454

@repokitteh-read-only

Copy link
Copy Markdown

Hi @akamathdev, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #46688 was opened by akamathdev.

see: more, trace.

std::optional<size_t> max_length)
: main_header_(main_header), alternative_header_(alternative_header), max_length_(max_length) {}
std::optional<size_t> max_length,
std::optional<bool> multi_value)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am looking for early feedback on the approach before spending more effort on this. There are likely more places the issue is asking to change as well that I need to consider

@yanavlasov yanavlasov self-assigned this Aug 16, 2026
@phlax

phlax commented Aug 19, 2026

Copy link
Copy Markdown
Member

@akamathdev could you fix DCO please

Existing format specifiers will only emit the first occurrence of a
header. Introduce new format specifiers that allow to print all
occurrences of a given header both in the request and response.

Signed-off-by: Aditya Kamath <[email protected]>
@akamathdev
akamathdev temporarily deployed to external-contributors August 20, 2026 05:04 — with GitHub Actions Inactive
@akamathdev

Copy link
Copy Markdown
Contributor Author

@phlax DCO has been fixed

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

The approach looks good to me.

/wait

absl::string_view alternative_header,
std::optional<size_t> max_length)
: main_header_(main_header), alternative_header_(alternative_header), max_length_(max_length) {}
std::optional<size_t> max_length, std::optional<bool> multi_value)

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.

Do you need the multi_value to be optional?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially expected this class to be used elsewhere and was going to make a separate constructor without the new field, but since that didn't turn out to be the case, yes it doesn't have to be optional

Add test for new format specifiers

Signed-off-by: Aditya Kamath <[email protected]>
yanavlasov
yanavlasov previously approved these changes Sep 17, 2026
@yanavlasov

Copy link
Copy Markdown
Contributor

LGTM. Sorry for the delay.

@yanavlasov

Copy link
Copy Markdown
Contributor

Oh, almost forgot. Please add the new substitution formatters to the doc.

/wait

@akamathdev

Copy link
Copy Markdown
Contributor Author

@yanavlasov Thank you for the callout. I have updated the substitution formatter docs as well as added a new file to the changelogs/current folder.

HTTP
An HTTP request header where ``X`` is the main HTTP header, ``Y`` is the alternative one, and ``Z`` is an
optional parameter denoting string truncation up to ``Z`` characters long. The value is taken from
the HTTP request header named ``X`` first and if it's not set, then request header ``Y`` is used. Only the

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is weird, but the primary change is the addition of this sentence

Only the first occurrence of the header is logged.

yanavlasov
yanavlasov previously approved these changes Sep 18, 2026
@akamathdev

Copy link
Copy Markdown
Contributor Author

Will get to the build issues in a day or two

@akamathdev

Copy link
Copy Markdown
Contributor Author

@yanavlasov Looks like the CI doesn't run until you approve and I am unable to run the test causing the build failure locally, do you have tips on getting around this so I can be confident of the fix before asking for your approval again ?

akamath@adityas-mbp envoy % bazel test -c dbg //test/common/formatter:substitution_formatter_test \
       --test_filter=SubstitutionFormatterTest.headersByteSizeFormatter \
       --test_output=streamed \
       --cache_test_results=no
Starting local Bazel server (8.7.0) and connecting to it...
WARNING: WORKSPACE support will be removed in Bazel 9 (late 2025), please migrate to Bzlmod, see https://bazel.build/external/migration.
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Analyzed target //test/common/formatter:substitution_formatter_test (597 packages loaded, 29662 targets configured).
ERROR: /private/var/tmp/_bazel_akamath/a7be6900953349bda30e4ecc88363827/external/com_google_protobuf/upb/mini_descriptor/BUILD:45:11: Compiling upb/mini_descriptor/internal/base92.c [for tool] failed: absolute path inclusion(s) found in rule '@@com_google_protobuf//upb/mini_descriptor:internal':
the source file 'upb/mini_descriptor/internal/base92.c' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/SDKSettings.json'
ERROR: /private/var/tmp/_bazel_akamath/a7be6900953349bda30e4ecc88363827/external/com_google_protobuf/upb/mem/BUILD:14:11: Compiling upb/mem/alloc.c [for tool] failed: absolute path inclusion(s) found in rule '@@com_google_protobuf//upb/mem:mem':
the source file 'upb/mem/alloc.c' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/SDKSettings.json'
Target //test/common/formatter:substitution_formatter_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /Users/akamath/Documents/dev/envoy/test/mocks/http/BUILD:61:14 Compiling test/mocks/http/mocks.cc failed: absolute path inclusion(s) found in rule '@@com_google_protobuf//upb/mem:mem':
the source file 'upb/mem/alloc.c' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/SDKSettings.json'
INFO: Elapsed time: 5.218s, Critical Path: 0.34s
INFO: 70 processes: 2024 action cache hit, 69 internal, 1 darwin-sandbox.
ERROR: Build did NOT complete successfully
//test/common/formatter:substitution_formatter_test             FAILED TO BUILD

Executed 0 out of 1 test: 1 fails to build.
akamath@adityas-mbp envoy %

@yanavlasov
yanavlasov temporarily deployed to external-contributors October 6, 2026 02:19 — with GitHub Actions Inactive
@yanavlasov

Copy link
Copy Markdown
Contributor

Sorry, I have missed this one. Merged main and started CI.

@yanavlasov

Copy link
Copy Markdown
Contributor

I've merged main, but it now has build errors.

/wait

Signed-off-by: Aditya Kamath <[email protected]>
@akamathdev

Copy link
Copy Markdown
Contributor Author

@yanavlasov could you please trigger the build again please

@yanavlasov
yanavlasov temporarily deployed to external-contributors November 4, 2026 22:53 — with GitHub Actions Inactive
@akamathdev

Copy link
Copy Markdown
Contributor Author

/retest

@yanavlasov
yanavlasov enabled auto-merge (squash) November 30, 2026 15:53
@yanavlasov

Copy link
Copy Markdown
Contributor

/retest

@yanavlasov

Copy link
Copy Markdown
Contributor

@akamathdev sorry for the delay. The CI seems to be stuck and I'm unable to get it unstuck. Can you please merge main to re-start CI please?

/wait

@yanavlasov
yanavlasov requested a deployment to external-contributors December 3, 2026 15:14 — with GitHub Actions Waiting
@akamathdev
akamathdev deployed to external-contributors December 3, 2026 15:14 — with GitHub Actions Active
@yanavlasov
yanavlasov merged commit 2b347a5 into envoyproxy:main Dec 3, 2026
21 of 25 checks passed
@akamathdev

Copy link
Copy Markdown
Contributor Author

Thanks @yanavlasov for taking care of this.

This branch was successfully deployed

1 active deployment
external-contributors — adfe2f4d Deployed Dec 3, 2026 by akamathdev via authorize #64157
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.

3 participants