Skip to content

fix: try_json_parse で JSON パースエラーのみを捕捉するよう修正#26

Open
aobathree wants to merge 1 commit into
bitbankinc:masterfrom
aobathree:fix/bare-except
Open

fix: try_json_parse で JSON パースエラーのみを捕捉するよう修正#26
aobathree wants to merge 1 commit into
bitbankinc:masterfrom
aobathree:fix/bare-except

Conversation

@aobathree

Copy link
Copy Markdown

概要

utils.pytry_json_parse は裸の except: を使用しているため、KeyboardInterruptSystemExit を含むすべての例外を「不正な JSON」エラーとして変換してしまい、障害時の原因特定を困難にします。

変更内容

捕捉対象を ValueError に限定しました。response.json() が JSON パース失敗時に送出する JSONDecodeErrorjson.JSONDecodeError / simplejson.JSONDecodeError)はいずれも ValueError のサブクラスであるため、正常系・異常系の従来挙動は変わりません。

🤖 Generated with Claude Code

try_json_parse の裸の except: は KeyboardInterrupt や SystemExit を
含むすべての例外を「不正なJSON」エラーとして握りつぶしてしまうため、
JSON パース失敗を示す ValueError のみを捕捉するように変更しました。

requests の response.json() が送出する JSONDecodeError
(json.JSONDecodeError / simplejson.JSONDecodeError) はいずれも
ValueError のサブクラスであり、従来の正常系・異常系の挙動は
変わりません。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@soichirokodama

Copy link
Copy Markdown
Collaborator

プルリクエストの作成ありがとうございます。
内容について社内で確認させていただきます。
よろしくお願いします。

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