Skip to content

fix(mcp): align env token precedence with the documented order - #6342

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6262
Jul 16, 2026
Merged

fix(mcp): align env token precedence with the documented order#6342
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetienhiep:fix/issue-6262

Conversation

@nghetienhiep

Copy link
Copy Markdown
Contributor

fix(mcp): align env token precedence with the documented order

getEnvApiToken() resolved LOOPOVER_TOKEN ahead of LOOPOVER_MCP_TOKEN, the
opposite of the precedence documented everywhere else. The README, printHelp,
the missing-auth error, and the diagnostic sanitizer list all read
"LOOPOVER_API_TOKEN, LOOPOVER_MCP_TOKEN, LOOPOVER_TOKEN" -- getEnvApiToken was
the single outlier, so a user setting the MCP-specific token got the generic
LOOPOVER_TOKEN instead when both were present.

Fix the code to match the documented order (API > MCP > TOKEN) and pin the
exact runtime precedence with a test that observes which token the CLI actually
sends as the Authorization header.

Closes #6262

getEnvApiToken() resolved LOOPOVER_TOKEN ahead of LOOPOVER_MCP_TOKEN, the
opposite of the precedence documented everywhere else. The README, printHelp,
the missing-auth error, and the diagnostic sanitizer list all read
"LOOPOVER_API_TOKEN, LOOPOVER_MCP_TOKEN, LOOPOVER_TOKEN" -- getEnvApiToken was
the single outlier, so a user setting the MCP-specific token got the generic
LOOPOVER_TOKEN instead when both were present.

Fix the code to match the documented order (API > MCP > TOKEN) and pin the
exact runtime precedence with a test that observes which token the CLI actually
sends as the Authorization header.

Closes JSONbored#6262
@nghetienhiep
nghetienhiep requested a review from JSONbored as a code owner July 16, 2026 02:54
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 16, 2026
@loopover-orb

loopover-orb Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-16 03:05:23 UTC

2 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a minimal, well-targeted one-line precedence fix: getEnvApiToken() now resolves LOOPOVER_API_TOKEN > LOOPOVER_MCP_TOKEN > LOOPOVER_TOKEN, matching the documented order everywhere else in the codebase. The new test file directly observes the Authorization header sent by the CLI across all three precedence combinations (API>MCP>TOKEN, MCP>TOKEN, TOKEN-only), which is a real end-to-end assertion against the actual request path rather than a fabricated unit check. The fix closes #6262 and is scoped tightly to the bug.

Nits — 4 non-blocking
  • The inline comment in loopover-mcp.js is fairly long for a one-line change; a shorter comment referencing the doc order would suffice.
  • The test file doesn't explicitly assert the reverse regression case (MCP_TOKEN alone without TOKEN set), though the three cases shown do adequately cover the precedence chain.
  • Consider trimming the comment in getEnvApiToken() to a single line since the PR description already explains the rationale in full.
  • Possible secret-shaped assignment in the diff (generic_secret_assignment) — Verify the value is not a real credential.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #6262
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 112 registered-repo PR(s), 64 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nghetienhiep; Gittensor profile; 112 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: minor
Linked issue satisfaction

Addressed
The code fix changes getEnvApiToken() precedence to LOOPOVER_API_TOKEN ?? LOOPOVER_MCP_TOKEN ?? LOOPOVER_TOKEN, matching the documented order, and a new test suite pins the exact precedence by observing the Authorization header sent for each combination of env vars.

Review context
  • Author: nghetienhiep
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 112 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit a2f762a into JSONbored:main Jul 16, 2026
14 checks passed
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.60%. Comparing base (d4a2c64) to head (5f702b3).
⚠️ Report is 28 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6342   +/-   ##
=======================================
  Coverage   95.60%   95.60%           
=======================================
  Files         597      597           
  Lines       47185    47185           
  Branches    15017    15017           
=======================================
  Hits        45113    45113           
  Misses       1290     1290           
  Partials      782      782           
Flag Coverage Δ
shard-1 44.16% <ø> (ø)
shard-2 36.40% <ø> (-0.13%) ⬇️
shard-3 32.54% <ø> (+0.12%) ⬆️
shard-4 34.63% <ø> (+<0.01%) ⬆️
shard-5 31.58% <ø> (-0.01%) ⬇️
shard-6 44.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@github-actions github-actions Bot mentioned this pull request Jul 16, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mcp): documented GITHUB/LOOPOVER token env-var precedence contradicts the actual implementation

1 participant