Skip to content

Fix: Ruby 3.4 compatibility for JSON.generate#401

Open
Tonguechaude wants to merge 1 commit into
puppetlabs:mainfrom
Tonguechaude:fix/ruby-3.4-json-generate
Open

Fix: Ruby 3.4 compatibility for JSON.generate#401
Tonguechaude wants to merge 1 commit into
puppetlabs:mainfrom
Tonguechaude:fix/ruby-3.4-json-generate

Conversation

@Tonguechaude

Copy link
Copy Markdown

Summary

Ruby 3.4 compatibility: TypeError in puppet_strings_helper.rb

The puppet-languageserver-sidecar crashes on Ruby 3.4.7 when attempting to index Puppet types, preventing the LSP from providing information about native Puppet resources (package, user, file, etc.).

Additional Context

Add any additional context about the problem here.

  • OS: Arch Linux (kernel 6.17.9)
  • Ruby version: 3.4.7 (2025-10-08)
  • Puppet version: 8.10.0 (gem)
  • puppet-editor-services version: 2.0.4
  • Installation method: Mason.nvim

Steps to Reproduce

  1. Install Ruby 3.4.7 (default on recent Arch Linux)
  2. Install puppet-editor-services 2.0.4
  3. Run the sidecar:
puppet-languageserver-sidecar --action=default_types

Expected Behavior

The sidecar should return a JSON array of all Puppet native types with their documentation.

Actual Behavior

The sidecar crashes with:

/usr/lib/ruby/3.4.0/json/common.rb:305:in `JSON::Ext::Generator::State.generate': 
wrong argument type Array (expected Hash) (TypeError)

      State.generate(obj, opts, nil)
                     ^^^^^^^^^^^^^^
	from /usr/lib/ruby/3.4.0/json/common.rb:305:in `JSON.generate'
	from lib/puppet-languageserver-sidecar/puppet_strings_helper.rb:373:in `to_json'

Root Cause

In lib/puppet-languageserver-sidecar/puppet_strings_helper.rb, line 373:

def to_json(*options)
  JSON.generate(to_h, options)  # Passes Array instead of unpacking
end

Related Issues (if any)

N/A

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified.

@Tonguechaude Tonguechaude requested a review from a team as a code owner December 9, 2025 11:23
@CLAassistant

CLAassistant commented Dec 9, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Tonguechaude

Copy link
Copy Markdown
Author

Hey can I have some news ?

just1602 added a commit to just1602/puppet-editor-services that referenced this pull request Jun 11, 2026
orignal: puppetlabs#401

Co-Authored-By Evan Challias <evan.challias@tonguechaude.fr>
just1602 added a commit to just1602/puppet-editor-services that referenced this pull request Jun 11, 2026
orignal: puppetlabs#401

Co-Authored-By: Evan Challias <evan.challias@tonguechaude.fr>
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