8000 A deleted or inaccessible linked app leaves `clerk deploy` with no working next step · Issue #568 · clerk/cli · GitHub
[go: up one dir, main page]

Skip to content

A deleted or inaccessible linked app leaves clerk deploy with no working next step #568

Open

Description

@shane-kercheval

What happens

The CLI remembers which Clerk app a project folder is linked to. If that app is later deleted, or the signed-in account loses access to it, the folder still points at it, and the CLI gives no working way out:

  1. clerk deploy (and clerk deploy status) asks Clerk for the linked app, gets "not found", and fails with a generic Platform API error. The friendlier "Clerk couldn't find this application... Run clerk link to re-link this directory" message in commands/deploy/errors.ts isn't applied to this first lookup.
  2. An AI agent that runs clerk link to fix it gets "Already linked to ()", exit code 0, and no change. In agent mode, clerk link in an already-linked folder returns early without checking that the app still exists.
  3. Rerunning clerk deploy fails the same way.

The commands that do work aren't mentioned anywhere in that path: clerk apps list --json, then clerk link --app <app_id> (which replaces the link), or clerk unlink --yes followed by clerk link --app <app_id>.

Who hits it

Anyone whose linked app was deleted or became inaccessible, mostly AI agents running in agent mode. A person in a terminal can get out with clerk link, which asks "Re-link to a different application?" and shows an app picker, but the error in step 1 doesn't point them there.

What the person experiences

  • clerk deploy fails with a raw API error and no next step.
  • An agent that tries clerk link is told the folder is already linked, and loops between clerk deploy and clerk link until a person steps in.
  • Nothing is lost or overwritten.

How big a deal it is

  • How often: rare. It needs an app deleted (or access removed) while a folder still points at it.
  • How bad when it happens: medium for agents, which can't recover alone; low for people.
  • Does it block them: yes, until someone runs clerk link --app <app_id> or clerk unlink --yes.
  • How we know: from reading the code. Step 1's exact output hasn't been reproduced.

Proposed fix

  • Map a 404 on the linked application in clerk deploy and clerk deploy status to a clear "this app no longer exists or isn't accessible" error, with advice that works:
    • agent mode: clerk apps list --json, then clerk link --app <app_id>;
    • person: clerk link, which offers to re-link.
  • Optionally, make agent-mode clerk link check that the saved app still exists, and give the same advice instead of "Already linked".

Where it goes: resolveLiveApplicationContext and resolveDeployState in packages/cli-core/src/commands/deploy/status.ts (the unwrapped fetchApplication calls), and the existing 404 message in packages/cli-core/src/commands/deploy/errors.ts. The optional part is in packages/cli-core/src/commands/link/index.ts.

Tests

  • With a linked folder whose app returns 404, agent-mode clerk deploy and clerk deploy status exit with the "app not found" error and advise clerk apps list --json then clerk link --app <app_id>.
  • Person mode advises clerk link.
  • Following the agent advice ends with the folder linked to the chosen app.

Reproduce

  1. Link a project folder to an app with clerk link --app <app_id>.
  2. Delete that app in the Clerk Dashboard.
  3. Run CLERK_MODE=agent clerk deploy, then CLERK_MODE=agent clerk link, then CLERK_MODE=agent clerk deploy again.

The first and last commands fail with an API error, and the middle one reports the folder is already linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0