Repository navigation
[NO-TICKET] Restore a hosted builder's lost key with login, in the CLI's messages and the docs - #465
Merged
Merged
Conversation
A hosted builder's workspace may not keep the git-ignored key file, so a later scan finds no key. AGENT-INSTALL.md now says to run `login` there, never to ask the person for a key or open the builder's secrets form, to remove a wrong PATCHSTACK_API_KEY secret first, and to scan and publish again after approval because rotating retires the read-only credential the published app carries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
/review |
|
🎯 Elite quality (97%) — Consistently reroutes hosted-builder key recovery to 📦 Small 🤖 Written by Claude Code — going by its own attribution. Unknown whether a person read it; agents can report that with the |
…ages In a Lovable or Replit project, the messages for a missing or refused key now say to run login in the builder's workspace, then scan and publish again. They no longer offer PATCHSTACK_API_KEY, which sent agents to the builder's secrets form to ask the person for a key they were never shown. login's own output says the same there, and on any machine warns when PATCHSTACK_API_KEY or PATCHSTACK_PULSE_AUTH is set, since either one is read before the key login saves. A builder's project deployed through a platform that identifies itself keeps the environment-variable advice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loginlogin, in the CLI's messages and the docs
Contributor
Author
|
/review |
The builder messages no longer say "read-only credential", "git-ignored" or "read before": the agent passes these on to the person, so they say what happens instead (the live site keeps getting new protection rules, the secret overrides the new key). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daniloradovic
approved these changes
Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No ticket.
What changed
When a hosted builder's workspace (Lovable, Replit, Bolt and similar) loses its API key, or has it refused, agents are now told one thing: run
login. The person approves one link and a new key is saved. Nobody types or pastes a key.It is said in two places:
login's output now say to runlogin, thenscan, then publish again. They no longer offerPATCHSTACK_API_KEY.AGENT-INSTALL.md, for agents that read the docs.Why
The published app of a hosted builder does not need the site key. It fetches rules and reports with the read-only credential bundled in its rules file. The workspace
scanstill needs the key, because the read-only credential cannot send a package list.That key lives in
.patchstackrc.local.json, which git ignores. A builder's workspace may not keep git-ignored files, so a scan a few hours after setup can find no key.The CLI's message for that case offered two fixes: "Run npx @patchstack/connect login, or set PATCHSTACK_API_KEY." A keyless builder copy, which is also what a direct
scanin that workspace runs as, printed "Set PATCHSTACK_API_KEY in the platform's environment". An agent that took the second option opened the builder's secrets form and asked the person for a key. Setup never shows the person the key, so they had nothing correct to paste. Patchstack refused whatever they entered, and the agent then sent them to the dashboard to make a new one.Agents act on the error text they are looking at, not on docs they read at install time, so the docs alone did not stop it. That is why the CLI text changes too.
Two more traps sit after
loginitself:PATCHSTACK_API_KEY(andPATCHSTACK_PULSE_AUTH) are read before.patchstackrc.local.json, so a bad value left in the workspace overrides the keyloginrestores.loginreplaces the key, and that also cancels the read-only credential the published app carries. The app needs a new one, which only reaches it with the next publish.login's output said to update "hosting", which in a builder sends the agent back to the secrets form.Fix
CLI:
resolveConfig(src/config.ts) now carries the hosted builder the project belongs to (hostedBuilder), from the samedetectHostedBuilder()check the environment label already used.restoresKeyWithLogin()(src/client.ts) is true for a builder's project, unless a deploy platform identified itself. A Lovable app deployed through Vercel or Netlify keeps today'sPATCHSTACK_API_KEYadvice, because that platform's environment is where the key belongs there.authFailureMessage, missing key: runloginin the builder's workspace, don't ask the person for a key, thenscanand publish again;authFailureMessage, refused key: the same, after removing anyPATCHSTACK_API_KEYsecret;undeliveredReportLines(src/build-hook.ts): restore the key withlogin, don't add it as a secret;postInputMap's skipped message: the workspace sends the map, and restores its key withlogin;login(src/cli.ts): before approval, "the app has to be published again afterwards"; after it, "run scan, then publish again" instead of "update it in CI, hosting and other checkouts".loginnow also warns after approval whenPATCHSTACK_API_KEYorPATCHSTACK_PULSE_AUTHis set, since either keeps the old key in use.AGENT-INSTALL.md:scansays the key is missing or was not accepted, runlogin. Do not ask the person for the key.login": a builder's workspace losing the file is now one of the listed reasons to use it.login:loginis the fix, and in a Lovable or Replit project the CLI's messages say so.PATCHSTACK_API_KEY, which they name elsewhere, is for CI and for hosts the person deploys to themselves.PATCHSTACK_API_KEYsecret first.login, runscan, then ask the person to publish again.scanso the new read-only credential goes into the guard's rules file, then publish again. Until then the live app cannot fetch new rules or report what it blocks.Verified
tests/auth-failure-message.test.ts:loginand the republish, neverPATCHSTACK_API_KEYas a fix;login.tests/build-hook.test.ts: a builder copy's lines point atloginand no longer say to setPATCHSTACK_API_KEY; they still name where they looked.tests/config.test.ts:hostedBuilderis read from the project's ownpackage.json.scanwith no key prints theloginsteps and "do not add the key as a secret";scanwith a wrongPATCHSTACK_API_KEYprints "remove it first", then theloginsteps.loginend to end against a stub that approves at once:PATCHSTACK_API_KEYis still in use;resolveConfig.persistApiKeywrites the key file. A keyedscanre-syncs the rules file and its read-only credential throughsyncWorkspace.npm run typecheck,npm run buildandcapabilities:checkare green.npm test: 4656 passed, 7 skipped. One test failed: "keeps scan, setup and guide free of technical words" hit its 5 s timeout under full-suite load, and passes on its own (39/39 intests/bin-invocation.test.ts).Out of scope, worth a follow-up
PATCHSTACK_API_KEYand the docs carry the guidance alone.loginmeans a rescan and a republish. A lasting fix is for the read-only credential to also send the package list, the way it already sends detections, so the workspace never needs the key. That needs a SaaS change and a decision about who may update a site's package list.Docs:
AGENT-INSTALL.mdupdated, and the CLI's error text changes what agents read. The test fixture installs the published package, so a run now would audit the previous text. The hostile field test is owed after the release that carries this (node field-test/run.mjs --persona hostile --rounds 3), plusstandard/lovablefor doc accuracy.🤖 Generated with Claude Code