Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] JSON payload decoding raises ArgumentError with json 3.x (JSON.parse options are keyword-only)

未关闭 适合新手
#595 4 条评论 0 个 reaction 已指派 2 人 在 GitHub 查看

维护者通常 1 天内回复

@GregoryTravis 已经在做这个了。

开始于 2026年10月13日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
json, ruby
领域
backend

调研方向

从 temporalio/lib/temporalio/converters/payload_converter/json_plain.rb 开始,并使用 json 3.x 运行最小复现。检查两个 JSON.parse 调用路径,并验证 payload 解码在 json 2.x 和 3.x 下都能正常工作,包括经过编码的失败属性,同时确保 JSON 生成不受影响。

由索引模型根据 Issue 内容生成。

描述

What are you really trying to do?

Decode JSON payloads (and failures with encode_common_attributes: true) with json 3.x installed.

Describe the bug

json 3.0 changed JSON.parse to take its options as keyword arguments only:

def parse(source, on_load: nil, object_class: nil, array_class: nil, **options)

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.

主要语言
Ruby
星标
207
派生
45
平均合并
1 天 16 小时
30 天内合并 PR
25

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

temporalio/sdk-ruby 的其他 Issue

查看 temporalio/sdk-ruby 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。