Skip to content

feat: accept empty content body in HttpJsonTranscodingService - #6325

Merged
minwoox merged 1 commit into
line:mainfrom
DongHyukki:accept-empty-body-when-content-type-json
Jul 30, 2025
Merged

feat: accept empty content body in HttpJsonTranscodingService#6325
minwoox merged 1 commit into
line:mainfrom
DongHyukki:accept-empty-body-when-content-type-json

Conversation

@DongHyukki

Copy link
Copy Markdown
Contributor

Motivation

HttpJsonTranscodingService currently fails with 400 Bad Request when handling a request with Content-Type: application/json and no body, even if the corresponding google.api.http rule uses body: "*". This behavior is inconsistent with common implementations such as Envoy and grpc-gateway, which treat empty bodies as {} in such cases.

Modifications

  • HttpJsonTranscodingService
    • Added a fallback to use an empty JSON object when body empty ( content-length: 0 )
    • Treat empty request bodies as {} when all of the following are true:
      • Content-Type: application/json
      • google.api.http rule: body: "*"

Result

@DongHyukki

Copy link
Copy Markdown
Contributor Author

@minwoox
Hi! This PR fixes #6319
When you have a moment, could you please take a look? Thank you!

@ikhoon ikhoon added the defect label Jul 29, 2025
@ikhoon ikhoon added this to the 1.33.0 milestone Jul 29, 2025
@codecov

codecov Bot commented Jul 29, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (8150425) to head (b90e9d7).
⚠️ Report is 130 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #6325       +/-   ##
============================================
- Coverage     74.46%       0   -74.47%     
============================================
  Files          1963       0     -1963     
  Lines         82437       0    -82437     
  Branches      10764       0    -10764     
============================================
- Hits          61385       0    -61385     
+ Misses        15918       0    -15918     
+ Partials       5134       0     -5134     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DongHyukki
DongHyukki force-pushed the accept-empty-body-when-content-type-json branch from 1f036ed to b90e9d7 Compare July 29, 2025 06:18

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

Thanks!

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

Thanks! 👍

@minwoox
minwoox merged commit 3fecf35 into line:main Jul 30, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpJsonTranscodingService throws on empty DELETE body due to gRPC HttpRule mapping

4 participants