Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
CLI 側の
parse_responseは検証自体は厳密でしたが、レスポンス不正の多くをPROTOCOL_VERSION_MISMATCHに集約していたため、障害時に「本当にバージョン不一致なのか」「レスポンス形式不正なのか」「request_id の取り違えなのか」が判別しづらい状態でした。本PRでは、プロトコル関連エラーを用途別に分離し、利用者と Remote Script 実装者の双方が原因を素早く特定できるようにしました。
ユーザー影響
不正レスポンス発生時のエラーコードがより具体的になります。
PROTOCOL_VERSION_MISMATCH: 実際の protocol_version 不一致PROTOCOL_INVALID_RESPONSE: 必須キー欠落や型不正などのレスポンス形式不正PROTOCOL_REQUEST_ID_MISMATCH: request_id 不一致これにより、同じ終了コード (
ExitCode.PROTOCOL_MISMATCH) でも、エラーコード文字列から切り分けの初動が明確になります。根本原因
parse_responseの各検証分岐でAppErrorを投げる際に、実際の失敗理由に関係なくerror_code="PROTOCOL_VERSION_MISMATCH"が使われていました。修正内容
src/ableton_cli/client/protocol.py:_raise_protocol_errorに集約(DRY化)error.details不正:PROTOCOL_INVALID_RESPONSErequest_id不一致:PROTOCOL_REQUEST_ID_MISMATCHPROTOCOL_VERSION_MISMATCHsrc/ableton_cli/errors.py:PROTOCOL_INVALID_RESPONSE/PROTOCOL_REQUEST_ID_MISMATCHをExitCode.PROTOCOL_MISMATCHにマッピング追加tests/test_protocol.py:PROTOCOL_INVALID_RESPONSEPROTOCOL_REQUEST_ID_MISMATCHPROTOCOL_INVALID_RESPONSEtests/test_exit_codes.py:ExitCode.PROTOCOL_MISMATCHへ解決されることを追加検証検証
以下を実行し、すべて成功しました。
uv run python -m ableton_cli.dev_checksuv run ruff check .uv run ruff format --check .uv run pytest