Skip to content

Comments

Fix: Invalid JSON on gc-stats (#1801)#4

Open
MitchLewis930 wants to merge 1 commit intopr_054_beforefrom
pr_054_after
Open

Fix: Invalid JSON on gc-stats (#1801)#4
MitchLewis930 wants to merge 1 commit intopr_054_beforefrom
pr_054_after

Conversation

@MitchLewis930
Copy link

PR_054

* Fix: Invalid JSON on gc-stats

Credits of this patch should be for @jdsundberg, who reported the issue
but never sent a patch. Link to his bug report is below.

Closes puma#1687.

* Update tests so JSON response is correctly parsed

JSON without a whitespace between key and values wasn't being correctly
parsed (for example: `key: 'value'` was processed ok, but `key:'value'`
wasn't).
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 pull request fixes invalid JSON generation in the gc-stats endpoint by replacing manual JSON string construction and parsing with proper JSON library methods. The issue (puma#1801) was caused by fragile regex-based JSON parsing and manual string concatenation that didn't properly handle all JSON formatting requirements.

Changes:

  • Replaced manual JSON string construction in /gc-stats endpoint with GC.stat.to_json
  • Updated test to use JSON.parse instead of regex-based parsing for gc-stats response
  • Added require 'json' to both the status app and test file

Reviewed changes

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

File Description
lib/puma/app/status.rb Added json library import and replaced manual JSON string construction with to_json method for gc-stats endpoint
test/test_cli.rb Added json library import and replaced regex-based JSON parsing with JSON.parse in gc-stats test

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

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.

2 participants