Skip to content

fix: preserve head map keys when value is empty#1070

Merged
AlexStocks merged 4 commits intoapache:masterfrom
knyk-dev:fix/getty-headmap-empty-value
Mar 28, 2026
Merged

fix: preserve head map keys when value is empty#1070
AlexStocks merged 4 commits intoapache:masterfrom
knyk-dev:fix/getty-headmap-empty-value

Conversation

@knyk-dev
Copy link
Copy Markdown
Contributor

  • I have registered the PR changes.

What this PR does:

Which issue(s) this PR fixes:

Fixes #1069

Special notes for your reviewer:

The bug is in the valueLength == 0 branch of decodeHeapMap(). It clears key instead of keeping the decoded key and setting value to an empty string.

And the change is intentionally small and only touches the Getty read/write path plus a regression test.

Does this PR introduce a user-facing change?:
NONE

fix: preserve HeadMap keys when decoding empty header values in Getty RPC messages

@github-actions github-actions Bot added bug Something isn't working coding remoting and removed bug Something isn't working labels Mar 15, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.96%. Comparing base (1b526c3) to head (fde1f46).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1070      +/-   ##
==========================================
+ Coverage   56.91%   56.96%   +0.05%     
==========================================
  Files         266      266              
  Lines       17488    17487       -1     
==========================================
+ Hits         9953     9962       +9     
+ Misses       6706     6704       -2     
+ Partials      829      821       -8     

☔ View full report in Codecov by Sentry.
📢 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.

@github-actions github-actions Bot added the bug Something isn't working label Mar 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Getty RPC header decoding bug where decodeHeapMap() overwrote the decoded header key when the header value was an empty string, breaking RpcMessage.HeadMap round-tripping.

Changes:

  • Fix decodeHeapMap() to preserve the decoded key when valueLength == 0 and set value to "".
  • Remove a stray no-op fmt.Sprintln("done") line in the decode loop.
  • Add a regression test covering HeadMap entries with empty-string values.

Reviewed changes

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

File Description
pkg/remoting/getty/readwriter.go Corrects empty-value decoding behavior so HeadMap keys are not lost/overwritten.
pkg/remoting/getty/readwriter_test.go Adds a regression test verifying encode/decode round-trip preserves empty header values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

thunguo
thunguo previously approved these changes Mar 25, 2026
Copy link
Copy Markdown
Contributor

@thunguo thunguo left a comment

Choose a reason for hiding this comment

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

LGTM

AlexStocks

This comment was marked as off-topic.

Comment thread pkg/remoting/getty/readwriter.go
@AlexStocks AlexStocks merged commit 423a4dc into apache:master Mar 28, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working coding remoting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] decodeHeapMap drops HeadMap keys when the value is empty

5 participants