Fix: Invalid JSON on gc-stats (#1801)#4
Open
MitchLewis930 wants to merge 1 commit intopr_054_beforefrom
Open
Conversation
* 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).
There was a problem hiding this comment.
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-statsendpoint withGC.stat.to_json - Updated test to use
JSON.parseinstead 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_054