Skip to content

feat(cli): add allowlisted raw API command - #296

Merged
version-1 merged 5 commits into
mainfrom
feat/tq-api-command
Jul 30, 2026
Merged

feat(cli): add allowlisted raw API command#296
version-1 merged 5 commits into
mainfrom
feat/tq-api-command

Conversation

@version-1

Copy link
Copy Markdown
Owner

allowlist 制約付きの tq api コマンドを追加

Summary

issue-tracker の型付き CLI コマンドで公開されていない操作を、明示的な許可リストの範囲内で呼び出せる tq api コマンドを追加します。

主な変更点:

  • method と route template の allowlist に基づく raw API 呼び出しを追加
  • query、header、literal/file/stdin body と raw response 出力に対応
  • strict path validation、redirect 禁止、終了コード契約をテストで固定
  • CLI help と英日リファレンス・設計文書を同期更新

やったこと

  • tq api <method> <path> の引数解析と HTTP 転送を実装
  • POST /api/v1/attachments を一時的に allowlist から除外
  • transport 管理 header、完全 URL、encoded path、dot segment、不正 ID を送信前に拒否
  • HTTP 2xx、3xx–5xx、204、timeout、接続失敗、バイナリ本文のテストを追加
  • allowlist の件数、重複、集合一致を検証して意図しない許可拡張を防止
  • docs/references/tq(.ja).mddocs/design/api(.ja).md を更新

動作確認

  • go test -race -count=1 ./internal/cli/tq
  • go test ./...
  • git diff --check origin/main...HEAD

レビュー & 動作確認 チェックリスト

  • allowlist 境界 - OpenAPI の現行 route を網羅し、attachment POST/PATCH と未知 route を拒否すること
  • raw 入出力契約 - query、header、body、バイナリ response が意図せず変換されないこと
  • 終了コード - 2xx、HTTP error、transport error、usage error がそれぞれ契約どおりであること
  • 英日文書同期 - リファレンスと API 設計文書の内容が一致していること

推奨テスト計画:

  1. tq api GET /api/v1/issues --query states=ready で一覧を取得する
  2. JSON body を使う POST/PATCH を実行し、レスポンスが raw JSON で出力されることを確認する
  3. 未許可 route と POST /api/v1/attachments が終了コード 2 で拒否されることを確認する

その他気になることや相談ごと

POST /api/v1/attachments は multipart 対応を追加するまで一時的に対象外です。破壊的な API に対する確認プロンプトは表示しません。

Add a fail-closed tq api command with strict route validation, repeatable query and header options, request body input, raw response forwarding, and status-based exit codes.

Include CLI tests and synchronized English and Japanese API and command references.
Assert the complete method and route-template allowlist, and add CLI coverage for empty 204 responses, request timeouts, and connection failures.
Keep the production timeout at ten seconds while allowing CLI transport tests to inject a shorter timeout without mutating the client after construction.
Keep the production HTTP client timeout fixed at ten seconds and exercise shorter request deadlines through the command context instead of a mutable package global.
Separate API design responsibilities from CLI reference details, fill missing commands and states, reduce duplication and inconsistencies, and synchronize the English and Japanese documentation with more natural Japanese wording.
@version-1
version-1 merged commit 2aefa30 into main Jul 30, 2026
5 checks passed
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.

1 participant