Skip to content

Conversation

@rjan90
Copy link
Contributor

@rjan90 rjan90 commented Oct 15, 2025

JSON-RPC HTTP responses were returning Content-Type: text/plain; charset=utf-8 instead of the correct application/json. Added w.Header().Set("Content-Type", "application/json") in the ServeHTTP method for HTTP responses.

Ref: filecoin-project/lotus#13390

fix: JSON-RPC Incorrect Content-Type Header
Copilot AI review requested due to automatic review settings October 15, 2025 08:39
Copy link

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

This PR fixes an issue where JSON-RPC HTTP responses were returning an incorrect Content-Type header (text/plain; charset=utf-8) instead of the proper application/json. The fix ensures JSON-RPC responses have the correct MIME type as expected by clients.

Key changes:

  • Added Content-Type header setting in the ServeHTTP method
  • Added comprehensive test coverage to verify the header fix and JSON response validity

Reviewed Changes

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

File Description
server.go Sets Content-Type header to "application/json" in ServeHTTP method
rpc_test.go Adds test to verify Content-Type header is correctly set to "application/json"

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@bd8f54a). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #139   +/-   ##
=========================================
  Coverage          ?   72.30%           
=========================================
  Files             ?       13           
  Lines             ?     1997           
  Branches          ?        0           
=========================================
  Hits              ?     1444           
  Misses            ?      453           
  Partials          ?      100           
Files with missing lines Coverage Δ
server.go 76.23% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rjan90 rjan90 requested review from Kubuxu and rvagg October 15, 2025 08:45
@rvagg rvagg changed the title fix: JSON-RPC Incorrect Content-Type Header fix(http): always set Content-Type to application/json Oct 21, 2025
@rvagg rvagg merged commit cbb61bb into master Oct 21, 2025
7 checks passed
@rvagg rvagg deleted the phi/incorrect-ct-header branch October 21, 2025 07:39
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.

4 participants