Repository navigation
[Backport 8.x] Port Puppet::Util::Json to the json 3 API - #721
Merged
Merged
Conversation
json 3.0.0 makes every option a keyword argument, raises on unknown options, and removes several deprecated APIs. Puppet::Util::Json relied on all three, so every agent run on a Ruby with json 3 installed failed with "wrong number of arguments (given 2, expected 1)" as soon as it deserialized anything (file metadata, catalogs, facts, module metadata). Changes to lib: * Util::Json.load passes parser options to JSON.parse as keywords. * Util::Json.dump replaces the removed JSON::PRETTY_STATE_PROTOTYPE with the equivalent generator options and drops the obsolete :quirks_mode option that the network formats still pass. Both methods now dup the options hash instead of mutating the caller's. * The epp and parser faces use JSON.pretty_generate instead of the removed JSON.pretty_unparse. * Pal's JsonCatalogEncoder#encode_resource goes through Util::Json.dump. It passed :pretty straight to Hash#to_json, which json 2 silently ignored and json 3 rejects. As a side effect it now honours the pretty option like #encode already did. Changes to spec, so the suite also passes with json 3: * Specs for load options and dump behaviour. * The schema matcher parses the JSON before handing it to json-schema, which as of 6.2.1 still calls JSON.parse with a positional hash. * The loaders spec fixture produced metadata.json with a duplicate "dependencies" key, which json 3 rejects by default. * Drop :create_additions from JSON.parse calls in the catalog spec; it was already the default and the option no longer exists. The Gemfile pin added in OpenVoxProject#655 is lifted to json < 4 so CI resolves json 3 and exercises this port. Everything still works with the json 2.x that ships with Ruby 3.2 through 4.0. Fixes OpenVoxProject#654 Closes OpenVoxProject#664 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Michael Harp <mike@mikeharp.com> (cherry picked from commit 8530418)
miharp
marked this pull request as ready for review
October 11, 2026 11:08
Sharpie
approved these changes
Oct 12, 2026
Sharpie
left a comment
Member
There was a problem hiding this comment.
Looks good to me. Replaces long, long deprecated methods like pretty_unparse and pushes option handling into the existing Puppet::Util::Json module.
This was referenced Oct 14, 2026
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.
Description
Backport of #655's follow-up #706 to
8.x. Fixes #720.json 3 reached the FreeBSD ports tree on 2026-09-29 (
devel/rubygem-json3.0.2). Theopenvox-server8port puts the system gem directory on JRuby'sgem-path, so a routinepkg upgrademade the server load json 3.0.2 and every request with a JSON body failed withCould not intern from json: wrong number of arguments (given 2, expected 1)(#720). An agent running the 8.x gem on a system Ruby next to json 3 fails the same way (#654).This cherry-picks the library commit from #706 (8530418) unchanged. It applies cleanly to
8.x. The second commit in #706, the gem-install smoke test job, is not carried:8.xdoes not have thetest_gem_buildandtest_installworkflow jobs it extends, so it conflicts intests.yamland there is nothing for it to plug into. That is also why the backport bot could not do this one.The backport bot label would have hit the same conflict, hence the manual PR.
Verification on
8.xunder json 3.0.28.xCI will not exercise json 3 even with theGemfilepin lifted to< 4, becauserubocop ~> 1.86.1depends onjson ~> 2.3(rubocop relaxed that to>= 2.3in 1.90, which is whatmainis on). So I verified locally on this branch with a rubocop-free bundle so bundler resolved json 3.0.2:rake parallel:spec[8]): 25297 examples, 19 failures. The 19 are the same user, service and package provider specs that fail on stock8.x(0d59f50) with json 2.21.2 on this macOS host, so none are from this change.puppet facts show,puppet parser dump --format json --pretty,puppet catalog compile --render-as jsonandpuppet apply --catalogof that output all succeed.With the stock
8.xbundle (json 2.21.2) the same suite is what CI runs here.Assisted by Claude.