Skip to content

fix(report): trim env values so stray newline in GITHUB_REPO can't break submissions#97

Merged
abdout merged 1 commit into
mainfrom
fix/report-github-repo-newline
May 22, 2026
Merged

fix(report): trim env values so stray newline in GITHUB_REPO can't break submissions#97
abdout merged 1 commit into
mainfrom
fix/report-github-repo-newline

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented May 22, 2026

Summary

  • "Report an issue" submissions on kun.databayt.org failed with "something went wrong, try again" for every user.
  • Root cause: the production GITHUB_REPO env var was set to "databayt/kun\n" (trailing newline, set 51 days ago). The adapter passed it verbatim into the GitHub issue URL, so createIssue POSTed to /repos/databayt/kun%0A/issues, threw, and the pipeline returned error: "internal" → the dialog showed its generic error.
  • The pipeline's symmetric-success design masked this — almost every other path returns ok:true, so a consistent error pointed straight at the two ok:false branches (missing token / createIssue throw).

Changes

  • src/lib/report/adapter.ts: .trim() GITHUB_REPO and REPORT_IP_SALT at read time.
  • src/lib/report/pipeline.ts: .trim() GITHUB_PERSONAL_ACCESS_TOKEN at read time.
  • Production GITHUB_REPO env var corrected (newline removed) out of band.

Test plan

  • Verified token + databayt/kun repo access locally (full push/issues perms, 200).
  • Confirmed databayt/kun\n produces a malformed/404 GitHub URL.
  • tsc clean for touched files (pre-existing unrelated .next/types layout errors remain).
  • After deploy: submit a report from kun.databayt.org/en/docs/onboarding and confirm success.

🤖 Generated with Claude Code

…eak submissions

Production GITHUB_REPO was set to "databayt/kun\n" (trailing newline). The
adapter passed it verbatim into the GitHub issue URL, so createIssue POSTed to
a malformed endpoint, threw, and the pipeline returned error:"internal" — every
report submission surfaced "something went wrong" to the user.

Trim GITHUB_REPO, REPORT_IP_SALT, and the GitHub token at read time so any stray
whitespace/newline in these env values can no longer break the report pipeline.
The prod env var has also been corrected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kun Ready Ready Preview, Comment May 22, 2026 3:52pm

@abdout abdout merged commit 3c24a5c into main May 22, 2026
2 checks passed
@abdout abdout deleted the fix/report-github-repo-newline branch May 22, 2026 15:52
abdout added a commit that referenced this pull request May 22, 2026
…#100)

Same env-newline class as the GITHUB token fix (#97): a trailing newline in
ANTHROPIC_API_KEY makes Anthropic reject the request with 401 invalid x-api-key,
silently dropping AI triage and forcing every report into needs-human. Trim the
key at read time. (Production AUTH_SECRET was also missing — set out of band — and
the prod ANTHROPIC_API_KEY value is currently junk pending a valid key.)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
abdout added a commit that referenced this pull request May 25, 2026
…el env pull (#111)

* docs(onboarding): bump Node 22 LTS → 24 LTS (Krypton) everywhere

Node 24.16.0 Krypton is the current Active LTS as of 2026-05-24; v22 Jod
moved to Maintenance. Updates onboarding.mdx (3 sites), all 3 OS install
scripts, wizard-steps.json, self-hosting.mdx NodeSource pin, and mcp.mdx
Playwright support line.

Mac now pins node@24 (was unpinned brew install node); Windows pins
OpenJS.NodeJS.LTS (was unpinned OpenJS.NodeJS); Linux stays on
nvm install --lts (auto-resolves to current LTS).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(onboarding): drop Tailscale + Apple Notes Dispatch; lean on native Anthropic surfaces

The optional Tailscale SSH and Apple Notes Dispatch sections contradict
the anthropic-native direction. Anthropic already ships the primitives we
should advertise instead: PushNotification tool (CLI → mobile),
claude.ai/code (remote control), computer-use beta (browser automation),
GitHub Issues + Slack MCP (team async).

Removed from onboarding flow:
- Optional row in Deliverables, Modify, wizard pre-flight, and Act 2 tables
- Entire "Remote control via Tailscale" + "Apple Notes Dispatch" sections
  → replaced with one "Remote control & async — native Anthropic surfaces"
  section that pitches the native primitives
- `--with-tailscale` / `-WithTailscale` flag (CLI + wizard + state schema)
- Phase 9 Tailscale block in onboarding-{mac,linux}.sh + onboarding-windows.ps1
- Apple Notes Dispatch-folder osascript block in onboarding-mac.sh
- Post-run "Re-run with --with-tailscale" hint in all 3 OS scripts
- /dispatch row from Daily entry points + Where-to-go-next link
- `dispatch` from .claude/CLAUDE.md Tier 2 commands + Tier 3 Operations
  vocabulary
- Tailscale VPN section + ACL table from self-hosting.mdx; updated
  cross-device row to point at mobile app + claude.ai/code

Hard-deleted (kept in git history):
- .claude/scripts/dispatch.sh
- .claude/commands/dispatch.md
- content/docs/dispatch.mdx

Known follow-up not in this commit (operational refactor needed):
- .claude/agents/captain.md and .claude/rules/cowork-bridge.md still
  reference dispatch.sh as the captain's escalation channel. These need
  a follow-up PR that switches captain to PushNotification +
  GitHub Issues + Slack MCP. Plan note added.
- Several product docs (cowork.mdx, captain.mdx, workflows.mdx,
  architecture.mdx, voice.mdx, tips.mdx, commands.mdx, slack.mdx) still
  document the dispatch.sh-based workflow; touched in Phase 5 sweep.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(onboarding): fail fast on missing databayt org membership + SSH push

Adds two pre-clone gates in Phase 3 of all three OS scripts (mac, linux,
windows) so a teammate can't proceed to Phase 4 cloning if their account
is misconfigured — instead of getting silent 404s on private repos:

1. databayt org membership via `gh api user/memberships/orgs/databayt
   --jq .state` — must return "active". On token-scope failure prints
   the gh auth refresh command; on inactive membership opens the invite
   page and exits.
2. SSH push capability via `ssh -T git@github.com` — grep the banner for
   "successfully authenticated" since GitHub always exits non-zero.

Also adds a wizard pre-flight prompt ("Have you accepted the databayt
org invite?") modeled on the existing GitHub-account question pattern,
persisted as `hasDatabaytInvite` in the installer state file. Modeled
on installer.sh:132 (the existing GitHub-account "Yes / No, create one
/ Skip" pattern). Mirrored across installer.sh, installer-linux.sh,
installer.ps1.

Default `gh auth login -p ssh -w` already requests `read:org` scope
(verified in gh CLI docs); no `-s` flag added.

wizard-steps.json schema gains hasGithub / hasDatabaytInvite /
hasAnthropic, plus the new pre-flight step entry. Phase 3 label in
docs + JSON now mentions the org gate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat(onboarding): vercel env pull per cloned product (.env from team databayt)

Vercel is the source of truth for app env vars; `~/.claude/.env` (from
the Gist) handles MCP keys + cross-cutting tokens. This bridges the gap:
each cloned product gets its `.env` from Vercel during onboarding.

New helpers:
- .claude/scripts/vercel-pull.sh   — loops `vercel link` + `vercel env
  pull .env --environment=development` across kun, hogwarts, codebase,
  souq, mkan, shifa, marketing under team `databayt`. Warn-and-continue
  on per-project failure; never abort.
- .claude/scripts/vercel-pull.ps1  — Windows equivalent.

All three OS scripts now:
- Phase 1: `npm install -g vercel` (next to pnpm install)
- Phase 6: invoke vercel-pull right after secrets.sh runs

If `vercel` CLI is missing or the user isn't logged in, the helper prints
a one-line warning and exits 0 so the install doesn't fail. Teammate
runs `vercel login` later and re-runs the bootstrap (idempotent).

onboarding.mdx updated:
- Side-tools row mentions Vercel CLI
- Verify table grows from 6 to 7 layers, adding NEW rows for org gate
  (Phase 3 work) and per-product env check
- Act 2 phase descriptions updated for Phase 1 (Vercel CLI) and Phase 6
  (Gist + Vercel env pull split)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: refresh secrets/credentials/commands docs to match anthropic-native onboarding

Brings parallel docs in line with the new onboarding flow:

content/docs/secrets.mdx — rewritten. Old doc listed 5 secrets and used
the wrong var name; reality is ~25 keys across 9 Gist sections plus
per-product Vercel env. New doc explains:
- Two-layer model: Gist (~/.claude/.env, cross-cutting + MCP) vs.
  vercel env pull (~/<repo>/.env, per-product app vars)
- secrets-template.json source-of-truth at .claude/scripts/
- The Vercel trailing-newline gotcha (PR #97 incident) + `printf` fix
- `.env` (not `.env.local`) convention per ~/.claude/CLAUDE.md
- Canonical var name `GITHUB_PERSONAL_ACCESS_TOKEN` (not `GITHUB_TOKEN`)
- Re-pull via bash ~/kun/.claude/scripts/vercel-pull.sh

content/docs/credentials.mdx — GITHUB_TOKEN → GITHUB_PERSONAL_ACCESS_TOKEN
across the 3 example commands. Var name now matches the convention used
across all databayt repos and ~/.claude/mcp.json.

content/docs/commands.mdx — drop the /dispatch row (Apple Notes
Dispatch was removed in the previous commit; the command file is gone).

content/docs/onboarding.mdx admin checklist (Before you sit down):
- GitHub row now mentions Phase 3 hard-gate
- New "Anthropic mobile app" row (native PushNotification dispatch)
- Vercel row promoted from engineer-only to **every role** — needed for
  vercel env pull
- New Neon row (project access for DATABASE_URL_*)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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