Skip to content

fix: honest API-key gating in the Add-column dialog#103

Merged
aaronjmars merged 2 commits into
mainfrom
fix/honest-key-gating
Jul 13, 2026
Merged

fix: honest API-key gating in the Add-column dialog#103
aaronjmars merged 2 commits into
mainfrom
fix/honest-key-gating

Conversation

@aaronjmars

Copy link
Copy Markdown
Collaborator

Problem

The Add-column picker under-reported which columns need a key. It dimmed a source only from capabilities.requiresEnv, and two things were off:

  1. github-stars and github-discussions hard-require a GITHUB_TOKEN (stargazers list is auth-gated; Discussions GraphQL gives unauthenticated requests ~0 quota) but declared it only in free-text rateLimitHint — so they showed as ready and only failed on refresh.
  2. The 6 xAI columns did declare requiresEnv, but .env.example ships XAI_API_KEY=xai-... — a non-empty placeholder. Boolean(process.env.XAI_API_KEY) counted it as configured, so those columns looked ready but failed on refresh with an opaque xAI "Incorrect API key", and Settings reported the key as set. ./minitor doctor already rejects the same placeholder.

Net: the UI showed 6 key-gated columns when 8 actually can't fetch without a credential — and even those 6 weren't dimmed when a placeholder was present.

Fix

  • Declare requiresEnv: ["GITHUB_TOKEN"] on github-stars + github-discussions.
  • Add a pure, client-safe isPlaceholderValue() to lib/env-keys.ts (blank or contains an ellipsis .../) and route all three key-presence reads through it: getKeyAvailability (dialog dimming), getEnvKeysStatus (Settings), and callGrok (fetch-time).

Now the dialog dims all 8 key-gated columns honestly in every env state, and a leftover placeholder fails with a clear "XAI_API_KEY is not set" instead of a bounced upstream call.

Verification

  • Live UI: 8 columns now dim with the key icon (6 xAI + stars + discussions), verified via DOM.
  • x-trending with the placeholder key → "XAI_API_KEY is not set in .env.local (still the .env.example placeholder?)" (was "Incorrect API key").
  • Keyless columns unaffected (e.g. hacker-news still returns items).
  • npm test275 pass (added test/env-keys.test.ts); eslint clean.

…picker

Both columns hard-require a token (the stargazers list is auth-gated; the
Discussions GraphQL API gives unauthenticated requests ~0 quota), but they
only advertised it via free-text rateLimitHint. The Add-column dialog dims a
source from capabilities.requiresEnv, so these two showed as ready and only
failed on refresh. Declare requiresEnv: ["GITHUB_TOKEN"] on both.
.env.example ships XAI_API_KEY=xai-... (a non-empty placeholder). Boolean(
process.env.X) counted it as configured, so the 6 xAI columns showed as ready
in the Add-column dialog but failed on refresh with an opaque xAI "Incorrect
API key", and Settings reported the key as set. ./minitor doctor already
rejects the same placeholder.

Add a pure isPlaceholderValue() helper (blank or contains an ellipsis) and use
it in getKeyAvailability + getEnvKeysStatus (Settings) and callGrok (fetch).
Now the columns dim honestly and a leftover placeholder fails with a clear
"XAI_API_KEY is not set" instead of a bounced upstream call.
@aaronjmars aaronjmars merged commit 30f481d into main Jul 13, 2026
2 checks passed
@aaronjmars aaronjmars deleted the fix/honest-key-gating branch July 13, 2026 15:02
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