You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] JSON payload decoding raises ArgumentError with json 3.x (JSON.parse options are keyword-only) #595
Temporalio::Converters::PayloadConverter::JSONPlain#from_payload passes them as a positional hash:
JSON.parse(payload.data, @parse_options)
(temporalio/lib/temporalio/converters/payload_converter/json_plain.rb, both branches, still present on main.)
So with json >= 3.0 every JSON payload decode raises:
ArgumentError: wrong number of arguments (given 2, expected 1)
json-3.0.2/lib/json/common.rb:296:in `parse'
temporalio-1.9.0/lib/temporalio/converters/payload_converter/json_plain.rb:55:in `from_payload'
temporalio-1.9.0/lib/temporalio/converters/payload_converter/composite.rb:66:in `from_payload'
temporalio-1.9.0/lib/temporalio/converters/data_converter.rb:90:in `from_payloads'
A quieter side effect: FailureConverter#from_failure ignores errors while decoding encoded_attributes, so with encode_common_attributes: true the decoded error's message is left as "Encoded failure" and nothing is raised.
Encoding is unaffected: JSON.generate(value, @generate_options) still accepts a positional hash in json 3.
temporalio.gemspec doesn't constrain json, so a fresh resolve picks up 3.x.
Minimal Reproduction
# Gemfile: gem "temporalio", "1.9.0"; gem "json", "3.0.2"
require "temporalio/converters"
dc = Temporalio::Converters::DataConverter.default
dc.from_payloads(dc.to_payloads([{ "a" => 1 }]))
# => ArgumentError: wrong number of arguments (given 2, expected 1)
Passes with json 2.21.2.
Suggested fix
Splat the options so it works on both json 2.x and 3.x:
JSON.parse(payload.data, **@parse_options)
and/or add json to the gemspec with a lower bound that supports keyword options.
Environment/Versions
temporalio 1.9.0 (also present on main)
json 3.0.2
Ruby 3.2, 3.3, 3.4 (reproduced on all three in CI; locally on 3.3.4, arm64-darwin)
Additional context
Workaround: pin gem "json", "< 3" in the application's Gemfile.
Confirmed on json 3.0.2 / Ruby 3.3. Splatting alone (**@parse_options) won't fix the default converter though: json 3.0 removed create_additions entirely, so JSON.parse(data, **{create_additions: true}) now raises 'unknown keyword: create_additions'. The default parse_options and the README's json_create / create_id example both depend on that option. Before touching code: do you want the default to drop create_additions when json >= 3, keep it behind a version check, or constrain json < 3 in the gemspec for now? Happy to put up a PR with tests once you pick a direction.
Confirmed on json 3.0.2 / Ruby 3.3. Splatting alone (**@parse_options) won't fix the default converter though: json 3.0 removed create_additions entirely, so JSON.parse(data, **{create_additions: true}) now raises 'unknown keyword: create_additions'. The default parse_options and the README's json_create / create_id example both depend on that option. Before touching code: do you want the default to drop create_additions when json >= 3, keep it behind a version check, or constrain json < 3 in the gemspec for now? Happy to put up a PR with tests once you pick a direction.
Thanks for confirming, and for spotting the create_additions removal. I hit the positional-args error first and didn't get past it.
From the consumer side, a gemspec constraint of json < 3 would be the quickest fix. Right now Bundler resolves temporalio with json 3, and every JSON payload decode fails at runtime. A constraint turns that into a resolve-time conflict, which is much easier to diagnose.
A proper fix can then come later without blocking anyone. It'll need a call on what replaces create_additions / json_create, since json 3 dropped that object-revival feature entirely, not just the option.
Workaround for anyone landing here: add gem "json", "< 3" to your app's Gemfile.
Limited the json dependency for the time being. With an on_load hook we can achieve recreate some of the create_additions behavior most of the time, but the edge cases where we wouldn't match the behavior would lead to unexpected objects returned from activities etc.
Activity
deepanshupal commentedon Oct 5, 2026
Confirmed on json 3.0.2 / Ruby 3.3. Splatting alone (**@parse_options) won't fix the default converter though: json 3.0 removed create_additions entirely, so JSON.parse(data, **{create_additions: true}) now raises 'unknown keyword: create_additions'. The default parse_options and the README's json_create / create_id example both depend on that option. Before touching code: do you want the default to drop create_additions when json >= 3, keep it behind a version check, or constrain json < 3 in the gemspec for now? Happy to put up a PR with tests once you pick a direction.
bray commentedon Oct 5, 2026
Thanks for confirming, and for spotting the
create_additionsremoval. I hit the positional-args error first and didn't get past it.From the consumer side, a gemspec constraint of
json < 3would be the quickest fix. Right now Bundler resolves temporalio with json 3, and every JSON payload decode fails at runtime. A constraint turns that into a resolve-time conflict, which is much easier to diagnose.A proper fix can then come later without blocking anyone. It'll need a call on what replaces create_additions / json_create, since json 3 dropped that object-revival feature entirely, not just the option.
Workaround for anyone landing here: add
gem "json", "< 3"to your app's Gemfile.chris-olszewski commentedon Oct 7, 2026
Limited the
jsondependency for the time being. With anon_loadhook we can achieve recreate some of thecreate_additionsbehavior most of the time, but the edge cases where we wouldn't match the behavior would lead to unexpected objects returned from activities etc.deepanshupal commentedon Oct 16, 2026
Thanks, the json pin in #607 covers it for me. I won't send a separate PR.