fix: preserve JSON-like string values in header override#1052
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical bug that caused JSON-like string values used in header overrides to be malformed. By refining the value rendering process, the change ensures that complex string structures, such as JSON, are accurately transmitted without unintended modifications, thereby improving the reliability of header manipulation. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly resolves an issue where JSON-like string values in header overrides were being improperly formatted. The change to use renderTemplate instead of renderOverrideValue and removing the fmt.Sprintf call ensures that header values are treated as strings, preserving their original format. A new test case has been added that specifically validates this fix, confirming that JSON-like strings are no longer corrupted. The changes are well-implemented and effectively address the described problem.
|
ci 挂了 |
|
我修下 |
643f5b0 to
71e7599
Compare
Problem
When setting header override values with JSON-like strings (e.g.,
{"session_id":"843634473"}), the previous implementation usedfmt.Sprintf("%v", renderedValue)which incorrectly formatted the value as a Go map literal withmap[prefix (e.g.,map[session_id:843634473]), corrupting the original JSON format.Solution
renderOverrideValuewithrenderTemplateto ensure proper string renderingfmt.Sprintf("%v", ...)formatting and pass the rendered value directly to preserve the original JSON string formatChanges
internal/server/orchestrator/override.go: Fixed header value assignment inapplyOverrideOperationToHeadersinternal/server/orchestrator/override_test.go: AddedTestOverrideHeadersKeepJSONLikeStringto verify JSON-like strings are preserved withoutmap[prefixTest Coverage
New test validates preservation of:
map[prefix contamination