Skip to content

fix(miro): start without a token and fail fast at first use - #5211

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/miro-fail-fast-unset-token
Sep 29, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/miro-fail-fast-unset-token

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Summary

An unset miro_api_token showed as an error in the /plugin menu (required: true, and the server exited at startup). Now:

  • plugin.json: required dropped from miro_api_token (still sensitive); description corrected.
  • Server starts without a token. Every tool call then returns one tool error naming the option and the fix, /plugin configure miro@melodic-software, plus the token URL and the MIRO_API_TOKEN alternative. Missing variable, empty string, and the literal ${user_config.miro_api_token} all count as unset. The change is in server/src/miro-client.ts (throwing client proxies instead of process.exit(1)), so no wrapper script.
  • With a token set, behavior is unchanged.
  • README, setup skill, and CHANGELOG updated; miro bumped 0.4.13 to 0.4.14; dist/index.min.js regenerated with npm run bundle. package-lock.json untouched. The vault-exec README recipe no longer needs a placeholder value.

Refs #5208

Verification run

  • npm run typecheck, npm test (7 files, 45 tests, includes starting the committed bundle over stdio with each of the three unset shapes and asserting the guidance error, plus a mocked-API token-set case): pass.
  • npm run verify-bundle: dist matches source. npm run lint: no errors (one existing biome schema-version info).
  • scripts/check-changelog-parity.sh --check and --check-bump origin/main: pass.
  • scripts/validate-plugins.sh, scripts/validate-plugin-contracts.mjs: pass.
  • markdownlint-cli2 on the three changed markdown files: 0 issues.

Not verified

The /plugin menu and /mcp were not tested live. Whether dropping required clears the Errors-tab row, and what ${user_config.*} becomes in MCP env when unset, are undocumented; the server guards all three shapes regardless. Close #5208 only after checking /plugin on a live install with miro enabled and no token.

🤖 Generated with Claude Code

https://claude.ai/code/session_01H4pw3AKPP9sNePN5qwf9jL

An unset miro_api_token showed as an error in the /plugin menu because the option was
required and the server exited at startup. Drop required (keep sensitive) and start the
server with clients that throw one setup error naming `/plugin configure
miro@melodic-software`. A missing variable, an empty string, and the unexpanded
`${user_config.miro_api_token}` text all count as unset. Behavior with a token is unchanged.

Regenerates dist/index.min.js. Bumps miro to 0.4.14.

Refs #5208

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H4pw3AKPP9sNePN5qwf9jL
@github-actions

Copy link
Copy Markdown
Contributor

PR body contract — issue linkage

This PR body does not yet satisfy the issue-linkage contract:

  • Missing a "## Fix" section. State the concrete change and how it addresses the problem.
  • Missing a "## Verification" section. Record concrete evidence the change works (commands, gates, output).
  • Missing a "## Related" section. List related PRs, ADRs, or decision-log entries this PR does not close.

Edit the body and this comment updates itself on the next run.

@kyle-sexton
kyle-sexton marked this pull request as ready for review September 29, 2026 01:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T01:50:32.405667Z ad1c7ec Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 56s —— View job


Security review complete

  • Gather context (PR diff, custom instructions)
  • Read changed files
  • Hunt for security-relevant issues
  • Adversarially validate candidates
  • Post findings

No security issues found.

Reviewed the token-handling change end to end (this PR's actual security-relevant surface):

  • plugins/miro/server/src/miro-client.ts — isTokenUnset catches the three unset shapes (absent, empty/whitespace, unexpanded ${user_config.miro_api_token}) before a real MiroApi/MiroLowlevelApi is ever constructed, so no request goes out with an empty/placeholder credential. When unset, unavailable() returns a Proxy whose get trap unconditionally throws a static MISSING_TOKEN_MESSAGE — the token value itself is never interpolated into any error text, log, or response, so there's no path for the secret (or a truncated/partial form of it) to leak through the new error-handling path.
  • plugins/miro/.claude-plugin/plugin.json — dropping required: true while keeping sensitive: true only changes when the value must be supplied, not how it's stored (still Claude Code's secure credential storage, never settings.json); no widening of storage or transport.
  • New tests (miro-client.test.ts, server-startup.test.ts, boards.test.ts) spawn the real committed bundle with an explicit env: { PATH, ...env }, which replaces rather than inherits the test runner's environment — so a real secret present in the CI environment can't leak into the spawned child even incidentally.
  • README / SKILL.md / CHANGELOG changes are documentation-only, consistent with the code change, and don't introduce any new credential-handling guidance (the vault-exec recipe already kept the token out of Claude Code's store; this PR just removes the now-unneeded placeholder-value step).

Net effect is a small security improvement: previously a required-but-possibly-empty token could reach new MiroApi(token)/new MiroLowlevelApi(token); now the guard is explicit and fails closed with a generic message instead of ever constructing a client with a bad credential.

No CRITICAL / IMPORTANT / SUGGESTION findings to report.
· Branch

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 5m 41s —— View job


Code review complete

  • Gather context (PR diff, changed files, custom instructions)
  • Invoke /review:code-review per custom instructions
  • Post inline comments for anchorable findings
  • Post summary comment

Summary

Reviewed the diff (plugin.json, CHANGELOG.md, README.md, SKILL.md, miro-client.ts, and the three new test files) against origin/main at ad1c7ec. The core fix is sound: createMiroClients now returns throwing Proxy stand-ins instead of calling process.exit(1), isTokenUnset correctly treats a missing variable, empty string, and the unexpanded ${user_config.miro_api_token} literal as unset, and the proxy approach is safe for how api/lowLevel are actually used in tools/*.ts (only method calls, no typeof/instanceof checks that the always-a-function get trap would break). The new tests (miro-client.test.ts, server-startup.test.ts, tools/boards.test.ts) exercise the unset/empty/placeholder shapes plus the token-set path and look correct.

Two inline findings on documentation left inconsistent with the fix itself (posted on the PR):

  • plugins/miro/.claude-plugin/plugin.json#L5 — the manifest's own top-level description still says "opt in and supply a Miro API token," contradicting the required: true removal two lines below.
  • plugins/miro/README.md#L17 — the "Enable it... and provide a token" lead-in wasn't updated alongside the table row right under it, which now says the opposite.

One cross-file finding with no changed line to anchor it to:

  • Dead code left behind: plugins/miro/server/src/stderr.ts exports writeStderr, whose only call site was the process.exit(1) path removed from miro-client.ts in this PR. A repo-wide search turns up zero remaining references to writeStderr or stderr.ts anywhere in the miro plugin. The module is now orphaned and should either be deleted or given a new purpose.

Everything else (bundle regeneration, version bump, CHANGELOG entry, SKILL.md wording) checks out against the source changes. The author's own "Not verified" note (live /plugin menu and /mcp behavior) is accurate — I did not independently verify that either, consistent with this being a CI-only review.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad1c7eca41

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/miro/skills/setup/SKILL.md Resolved
Comment thread plugins/miro/.claude-plugin/plugin.json Resolved
Comment thread plugins/miro/README.md Resolved
…d-in

The setup skill no longer reports a token as supplied from tool presence, since the server
now starts and lists tools without one; verify-api detects the unset state and routes to
/plugin configure. The manifest description and README lead-in no longer frame the token
as required to enable. docs/catalog.md regenerated.

Refs #5208

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H4pw3AKPP9sNePN5qwf9jL
@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 1m 52s —— View job


Security review complete

  • Gather context (PR diff, custom instructions)
  • Invoke /review:security-review and follow its instructions
  • Post findings

No security issues found.

Reviewed the full diff at HEAD 493452b (both commits) against the criteria in /review:security-review: token/credential handling, injection surfaces, and trust-boundary logic in the changed files.

  • plugins/miro/server/src/miro-client.ts — isTokenUnset catches all three unset shapes (absent, empty/whitespace, unexpanded ${user_config.miro_api_token}) before a real MiroApi/MiroLowlevelApi is constructed. When unset, unavailable() returns a Proxy whose get trap throws a static MISSING_TOKEN_MESSAGE (line 8-12) — the token value is never interpolated into any thrown text, so there's no path for a partial/placeholder credential to leak through the new error path. This is a net hardening versus the prior process.exit(1) path: no client is ever constructed with a bad credential.
  • plugins/miro/.claude-plugin/plugin.json — dropping required: true while keeping sensitive: true only changes when the value must be supplied, not how it's stored (still Claude Code's secure credential storage, never settings.json). The manifest description (line 5) and the userConfig description (line 25) are now consistent with each other and with the code, closing the doc/behavior contradiction an earlier review round flagged here — not a security finding itself, but confirms no stale guidance is steering a user toward an insecure workaround.
  • plugins/miro/server/src/server-startup.test.ts, miro-client.test.ts, tools/boards.test.ts — the new tests spawn the real committed bundle (or an in-memory transport) with env: { PATH, ...env }, which replaces rather than inherits the test runner's environment, so a real secret present in the CI environment can't leak into the spawned child even incidentally.
  • plugins/miro/skills/setup/SKILL.md, README.md, CHANGELOG.md, docs/catalog.md — documentation-only changes, consistent with the code, introduce no new credential-handling guidance. The setup skill's step 4 (tool presence ≠ credential proof) already states the token state is "unchecked" rather than implying a credential was verified, so it doesn't create a false-confidence trust-boundary gap.
  • plugins/miro/server/dist/index.min.js — generated bundle; the PR's own verification (npm run verify-bundle) confirms it matches source, so no separate line-by-line audit of the minified artifact was needed.

No instruction-surface deletions (no guardrail, check step, or allow/deny rule was removed or narrowed by this diff) and no GitHub Actions changes in scope.
· Branch

@claude

claude Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @kyle-sexton's task in 2m 13s —— View job


Code review complete (/review:code-review)

  • Gather context (PR diff, changed files, custom instructions)
  • Invoke /review:code-review per custom instructions
  • Post inline comments for anchorable findings
  • Post summary comment

Summary

Reviewed the latest commit (493452b), which addresses the three doc-consistency findings from the prior review round (ad1c7ec):

  • plugin.json description no longer says "opt in and supply a Miro API token" — now matches the userConfig.miro_api_token.description and the required: true removal.
  • README.md's enabling lead-in no longer says "and provide a token" as part of enabling — now "Set a token before first use," consistent with the Options table row underneath it.
  • SKILL.md step 4 no longer tells the setup skill to report "the token was supplied" from tool presence alone — it now says to report only that the server started, with the token state explicitly unchecked (addresses the Codex P2 finding on tool-presence-as-token-proof).

All three previously-flagged inconsistencies check out as fixed, and I didn't find any new inconsistency introduced by this wording pass (docs/catalog.md's generated blurb still matches plugin.json's description; the Output states in SKILL.md line 106 line up with the states each step actually reports).

One finding from the prior round remains open and unaddressed by this commit — no changed line in this PR carries it, so noting it here per the cross-file convention:

  • Orphaned module: plugins/miro/server/src/stderr.ts still exports writeStderr, and it's still unreferenced anywhere in the miro plugin (its only caller was the process.exit(1) path this PR removed from miro-client.ts). Delete the file or give it a new purpose.

The code itself (miro-client.ts, the three new test files) was unchanged by this commit and was already reviewed at ad1c7ec with no correctness issues found there.
· Branch

@kyle-sexton
kyle-sexton merged commit 863243e into main Sep 29, 2026
3 checks passed
@kyle-sexton
kyle-sexton deleted the fix/miro-fail-fast-unset-token branch September 29, 2026 02:04
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.

miro: unset miro_api_token shows as a /plugin error; fail fast at first use with setup guidance instead

1 participant