Bug found related to Boolean fields (with solution)
まだ誰も着手していません。
評価
調査の方向性
Inspect jsonschema.lua around line 701 and reproduce the failure with the Boolean oneOf schema and default value shown in the issue. Verify that validator generation handles Boolean defaults without the sformat error, and add or run a regression check if the repository provides one.
索引モデルが issue の本文から書いたものです。
説明
I found a bug when using boolean fields in my JSON Schema. My partial JSON Schema which I use to detect the error was the following:
...
"bool_param":{
"oneOf":[{
"type":"boolean"
},{
"enum":["external"]
}],
"default":true,
"description":"Description of bool_param. Set as 'external' if the value is not yet known and thus will be set externally at runtime (only once) depending on e.g. the outcome of a previous action or the outcome of another module."
},
...
When setting it to true or false, I got the following error when validating the schema:
lua: /usr/local/share/lua/5.1/jsonschema.lua:701: bad argument #4 to 'sformat' (string expected, got boolean)
stack traceback:
[C]: in function 'sformat'
/usr/local/share/lua/5.1/jsonschema.lua:701: in function 'generate_validator'
/usr/local/share/lua/5.1/jsonschema.lua:173: in function 'validator'
/usr/local/share/lua/5.1/jsonschema.lua:678: in function 'generate_validator'
/usr/local/share/lua/5.1/jsonschema.lua:173: in function 'validator'
/usr/local/share/lua/5.1/jsonschema.lua:1184: in function 'generate_main_validator_ctx'
/usr/local/share/lua/5.1/jsonschema.lua:1201: in function 'generate_validator'
./task_requirements.lua:501: in function 'load_json_table'
example.lua:35: in main chunk
[C]: ?
The bug was (apparently) easily fixed by changing line 701 of the jsonschema.lua from:
ctx:stmt(sformat(' %s[%s] = %s', ctx:param(1), str_filter(prop), default))
to
ctx:stmt(sformat(' %s[%s] = %s', tostring(ctx:param(1)), str_filter(prop), tostring(default)))
I guess this happens because lua does not convert booleans to strings automatically.
- 主要言語
- Lua
- スター
- 136
- フォーク
- 29
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
api7/jsonschema のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
api7/jsonschema#95 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
api7/jsonschema#105 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
api7/jsonschema#93 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
api7/jsonschema#92 ·
-
Support pcre2オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
api7/jsonschema#89 ·
api7/jsonschema の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
bug documentation lua
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
severity: low
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
luainkernel/lunatik#2148 ·
メンテナーはふだん 1 日以内に返信
-
Addon Conflict Bug Forever Module - Map / Minimap
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信