Skip to content

fix: API キーコマンドの --scopes ヘルプを実際に使用可能なスコープに修正#74

Merged
miya0001 merged 1 commit into
mainfrom
fix-api-key-scopes-help
Mar 17, 2026
Merged

fix: API キーコマンドの --scopes ヘルプを実際に使用可能なスコープに修正#74
miya0001 merged 1 commit into
mainfrom
fix-api-key-scopes-help

Conversation

@miya0001

@miya0001 miya0001 commented Mar 17, 2026

Copy link
Copy Markdown
Member

Summary

  • API キーコマンド (me api-keys create, admin api-keys create/update) のヘルプに表示されるスコープ一覧が、OAuth クライアント用の全スコープ(18種)を表示していた
  • サーバー側の API キー Zod スキーマ (ApiKeyScopeSchema) で受け付けるのは6スコープのみのため、API キー専用の API_KEY_SCOPES_HELP_NOTES を新設して正しいスコープのみ表示するよう修正
  • OAuth クライアント系コマンドは従来通り全スコープを表示する SCOPES_HELP_NOTES を使用

Valid API key scopes

read:entities, write:entities, read:subscriptions, write:subscriptions, read:registrations, write:registrations

Test plan

  • npm run lint パス
  • npm run typecheck パス
  • npm test 全624テストパス

Summary by CodeRabbit

バグ修正

  • API キーコマンド (me api-keysadmin api-keys) のヘルプ出力を修正し、API キーで実際に使用可能な6つのスコープのみを正確に表示するようにしました。これにより、ユーザーは API キーに適用される権限範囲をより明確に理解できるようになります。

@coderabbitai

coderabbitai Bot commented Mar 17, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

このプルリクエストは、APIキーコマンド(me api-keysadmin api-keys)のヘルプ出力を修正するもので、APIキーで実際に使用可能な6つのスコープを表示するために、汎用スコープヘルプ定数を専用のAPIキースコープヘルプ定数に置き換えています。

Changes

Cohort / File(s) Summary
APIキースコープヘルプ定数の定義
src/helpers.ts
APIキー固有のスコープ情報を含む新しいエクスポート定数API_KEY_SCOPES_HELP_NOTESを追加し、既存のSCOPES_HELP_NOTESをOAuthクライアント向けとして明確化。
コマンドでのスコープヘルプの置き換え
src/commands/admin/api-keys.ts, src/commands/me-api-keys.ts
インポートと使用箇所でSCOPES_HELP_NOTESAPI_KEY_SCOPES_HELP_NOTESに置き換え、APIキーコマンドで正確なスコープ情報を表示。
テストモックの更新
tests/admin-api-keys.test.ts, tests/admin-oauth-clients.test.ts, tests/admin-policies.test.ts, tests/admin-tenants.test.ts, tests/admin-users.test.ts, tests/auth.test.ts, tests/entities.test.ts, tests/health.test.ts, tests/me-api-keys.test.ts, tests/me-oauth-clients.test.ts, tests/setup-command-mocks.ts, tests/snapshots.test.ts, tests/temporal.test.ts, tests/types.test.ts
../src/helpers.jsのモック実装にAPI_KEY_SCOPES_HELP_NOTES: []プロパティを追加してテスト環境を更新。
変更ログ
CHANGELOG.md
2026-03-17の未リリース項目にAPIキーコマンドのヘルプ出力修正を記録。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 新しい定数がぴょんぴょん跳ねて、
APIキーのスコープはもっと清い!
テストも一緒にホップホップと、
正確なヘルプが輝く日よ。
混乱もなく、シンプルに進む。 ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、APIキーコマンドの --scopes ヘルプを実際に使用可能なスコープに修正するという変更内容を正確に反映しており、主な変更点を明確に要約しています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-api-key-scopes-help
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/commands/me-api-keys.ts (1)

2-7: 同一モジュールからの重複インポートを統合してください。

../helpers.js からのインポートが2行に分かれています。1つのインポート文に統合することを推奨します。

♻️ 修正案
-import { withErrorHandler, createClient, resolveOptions, getFormat, outputResponse } from "../helpers.js";
+import { withErrorHandler, createClient, resolveOptions, getFormat, outputResponse, API_KEY_SCOPES_HELP_NOTES } from "../helpers.js";
 import { loadConfig, saveConfig } from "../config.js";
 import { parseJsonInput } from "../input.js";
 import { printError, printWarning } from "../output.js";
 import { addExamples, addNotes } from "./help.js";
-import { API_KEY_SCOPES_HELP_NOTES } from "../helpers.js";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/me-api-keys.ts` around lines 2 - 7,
同一モジュール(../helpers.js)からの重複インポートを統合してください — 現在分かれている withErrorHandler,
createClient, resolveOptions, getFormat, outputResponse と
API_KEY_SCOPES_HELP_NOTES を1つのimport文にまとめ、不要な重複行を削除して1行でインポートするよう修正してください。
src/commands/admin/api-keys.ts (1)

2-7: 同一モジュールからのインポートを統合することを検討してください。

../../helpers.js からのインポートが2箇所に分かれています。1つのインポート文にまとめることで、可読性とメンテナンス性が向上します。

♻️ 提案する修正
-import { withErrorHandler, createClient, resolveOptions, getFormat, outputResponse } from "../../helpers.js";
+import { withErrorHandler, createClient, resolveOptions, getFormat, outputResponse, API_KEY_SCOPES_HELP_NOTES } from "../../helpers.js";
 import { loadConfig, saveConfig } from "../../config.js";
 import { parseJsonInput } from "../../input.js";
 import { printError, printWarning } from "../../output.js";
 import { addExamples, addNotes } from "../help.js";
-import { API_KEY_SCOPES_HELP_NOTES } from "../../helpers.js";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/admin/api-keys.ts` around lines 2 - 7, Summary: Two separate
import statements are pulling from the same module; merge them into one to
improve readability and maintainability. Fix: locate the two imports that
reference the same module (the imports that include withErrorHandler,
createClient, resolveOptions, getFormat, outputResponse and the separate import
of API_KEY_SCOPES_HELP_NOTES) and combine them into a single import statement
that lists all symbols (withErrorHandler, createClient, resolveOptions,
getFormat, outputResponse, API_KEY_SCOPES_HELP_NOTES); remove the now-redundant
import line and ensure there are no naming conflicts or duplicate symbols after
merging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/commands/admin/api-keys.ts`:
- Around line 2-7: Summary: Two separate import statements are pulling from the
same module; merge them into one to improve readability and maintainability.
Fix: locate the two imports that reference the same module (the imports that
include withErrorHandler, createClient, resolveOptions, getFormat,
outputResponse and the separate import of API_KEY_SCOPES_HELP_NOTES) and combine
them into a single import statement that lists all symbols (withErrorHandler,
createClient, resolveOptions, getFormat, outputResponse,
API_KEY_SCOPES_HELP_NOTES); remove the now-redundant import line and ensure
there are no naming conflicts or duplicate symbols after merging.

In `@src/commands/me-api-keys.ts`:
- Around line 2-7: 同一モジュール(../helpers.js)からの重複インポートを統合してください — 現在分かれている
withErrorHandler, createClient, resolveOptions, getFormat, outputResponse と
API_KEY_SCOPES_HELP_NOTES を1つのimport文にまとめ、不要な重複行を削除して1行でインポートするよう修正してください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 623eb732-7267-45fa-86f2-6f39a617b0a1

📥 Commits

Reviewing files that changed from the base of the PR and between f832141 and 09e9a12.

📒 Files selected for processing (18)
  • CHANGELOG.md
  • src/commands/admin/api-keys.ts
  • src/commands/me-api-keys.ts
  • src/helpers.ts
  • tests/admin-api-keys.test.ts
  • tests/admin-oauth-clients.test.ts
  • tests/admin-policies.test.ts
  • tests/admin-tenants.test.ts
  • tests/admin-users.test.ts
  • tests/auth.test.ts
  • tests/entities.test.ts
  • tests/health.test.ts
  • tests/me-api-keys.test.ts
  • tests/me-oauth-clients.test.ts
  • tests/setup-command-mocks.ts
  • tests/snapshots.test.ts
  • tests/temporal.test.ts
  • tests/types.test.ts

@miya0001
miya0001 merged commit 25697d2 into main Mar 17, 2026
7 checks passed
@miya0001
miya0001 deleted the fix-api-key-scopes-help branch March 17, 2026 14:59
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