Skip to content

Linked environments: a pairing code created on this machine is sent to the other machine and fails as "unknown, expired, or already used" #30181

Open

Description

@daan-nijhuis

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

Linked environments (link request card, peerLinks.link, Settings → Sharing & access)

Steps to reproduce

  1. T3 Code Desktop 0.1.5 (stable) on a Mac (environment bcd6…). A headless server 0.1.5 on a Linux host on the tailnet (a3b7…, https://<host>.ts.net:3773).
  2. Turn on Settings → Labs → Linked environments on the Mac.
  3. A thread on the Mac posts a link request card for the Linux host (environment id given).
  4. To get a code, open Settings → Sharing & access → Create link in the desktop app (the Mac's own settings, which is what the app shows) and paste it into the card right away.
  5. Approve. Repeat with a second fresh code and a second card.

Expected behavior

Either the card tells me where to create the code (on the machine being linked, with a way to open that machine's Sharing & access), or, when I paste a code this machine issued itself, it says so: "This code was created on MacBook, not on frontlink-dev. Create the link on frontlink-dev."

Actual behavior

Every attempt fails with "That pairing code is unknown, expired, or already used." even though the code is seconds old and unused.

The logs show why. The Mac's auth_pairing_links has both codes (labels "Environments" at 13:22:01Z and "Linked Environments" at 13:24:49Z, neither consumed). The Linux server gets POST /oauth/mcp/register and POST /oauth/mcp/decision, and EnvironmentAuth.consumeMcpApprovalCode fails with ServerAuthMcpApprovalCodeError because the code is not in its own table (the UPDATE auth_pairing_links SET consumed_at matches no row). The Mac reports PeerLinks.signIn → PeerLinkError: That pairing code is unknown, expired, or already used. three times (13:22:34Z, 13:22:42Z, 13:25:18Z).

The error suggests a timing problem, so I retried quickly several times; the real problem was which machine made the code.

Impact

Linking another machine looks broken. With nothing pointing at the cause, it is easy to give up on the feature.

Version or commit

Desktop 0.1.5 (stable, "T3 Code (Beta).app"), server 0.1.5 on Linux (systemd service). The latest stable is 0.1.6; I found no change about this in its notes.

Environment

macOS (arm64) desktop, Linux x64 headless server, both on Tailscale, T3 Connect on.

Notes

Related, not the same: #30088 (the same error message for an MCP sign-in, closed as a code from another server; the same trap, which suggests the message itself should name the cause), #27688 (Linked environments points to the wrong settings page), #26952 (the link card can't be dismissed).

Activity

  1. daan-nijhuis commented on Nov 3, 2026

    @daan-nijhuis
    Author

    One more data point: I switched the desktop app to the Linux environment before opening Settings → Sharing & access → Create link, and the code was still created on the Mac (the Mac's auth_pairing_links has it at 13:38:40Z; the Linux server's newest pairing link is from 12:20Z, a T3 Connect one). So from the desktop app there seems to be no way to create a link on the machine you want to link, and the card fails the same way each time.

  2. daan-nijhuis commented on Nov 3, 2026

    @daan-nijhuis
    Author

    What finally worked: a code created on the Linux host itself (t3 auth pairing create there), pasted into the card as the bare code. Pasting the full https://…/pair#token=… link from that same command into the card failed with the same "unknown, expired, or already used" message, so the card could also accept the link form, or at least say it wants the bare code.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions