From 7f9a018d75aa507d484f69517483b09f262ac0e9 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 16 Nov 2026 03:07:10 +0000 Subject: [PATCH 1/2] test(cli): t3 pair --tailscale explains a Serve config denied for lack of an operator Fails on main: the denied stderr becomes the generic "run it by hand" error. Refs #37459 Co-Authored-By: Claude Opus 5.5 --- apps/server/src/cli/pair.test.ts | 66 ++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/apps/server/src/cli/pair.test.ts b/apps/server/src/cli/pair.test.ts index 9619030be2fab..255dae1884bb9 100644 --- a/apps/server/src/cli/pair.test.ts +++ b/apps/server/src/cli/pair.test.ts @@ -623,6 +623,72 @@ describe("t3 pair", () => { assert.include(String(error), "127.0.0.2"); }).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), ); + + // regression: #37459 - on Linux without an operator, tailscaled refuses Serve config + // from a normal user, and the CLI must say how to fix it. + it.effect("explains the operator fix when Tailscale denies the Serve config", () => + Effect.gen(function* () { + const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-pair-remote-")); + yield* persistServerRuntimeState({ + path: NodePath.join(baseDir, "userdata", "server-runtime.json"), + state: yield* makePersistedServerRuntimeState({ + config: { host: "127.0.0.1", devUrl: undefined }, + port: 3773, + }), + }); + const spawner = ChildProcessSpawner.make((command) => { + const { args } = command as unknown as { readonly args: ReadonlyArray }; + const serve = args[0] === "serve" && args[1] !== "status"; + return Effect.succeed( + ChildProcessSpawner.makeHandle({ + pid: ChildProcessSpawner.ProcessId(1), + exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(serve ? 1 : 0)), + isRunning: Effect.succeed(false), + kill: () => Effect.void, + unref: Effect.succeed(Effect.void), + stdin: Sink.drain, + stdout: Stream.make( + new TextEncoder().encode( + serve + ? "" + : args[0] === "status" + ? '{"Self":{"DNSName":"pair-test.tail.ts.net."}}' + : "{}", + ), + ), + stderr: Stream.make( + new TextEncoder().encode( + serve + ? "sending serve config: Access denied: serve config denied\n\nUse 'sudo tailscale serve --https=443 --bg http://127.0.0.1:3773'.\nTo not require root, use 'sudo tailscale set --operator=$USER' once.\n" + : "", + ), + ), + all: Stream.empty, + getInputFd: () => Sink.drain, + getOutputFd: () => Stream.empty, + }), + ); + }); + + const error = yield* provideCliTestLayers( + runCli(["pair", "--base-dir", baseDir, "--tailscale"]).pipe( + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), + Effect.provideService(HostProcess.Platform, "linux"), + Effect.provideService(FetchHttpClient.Fetch, async (input) => { + if (String(input) === "http://127.0.0.1:3773/.well-known/t3/environment") { + return Response.json(testDescriptor); + } + assert.equal(String(input), "https://pair-test.tail.ts.net/.well-known/t3/environment"); + return new Response(null, { status: 503 }); + }), + Effect.flip, + ), + ); + + assert.include(String(error), "sudo tailscale set --operator=$USER"); + assert.notInclude(String(error), "by hand to see why"); + }).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))), + ); }); describe("auth scope options", () => { From 4ad3e51af98ef0b3159dfa5cdb19ce1bbe7c9816 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 16 Nov 2026 03:13:48 +0000 Subject: [PATCH 2/2] fix(cli): t3 pair --tailscale names the operator fix when Tailscale denies Serve Fixes pingdotgg/t3code#37459 Co-Authored-By: Claude Opus 5.5 --- apps/server/src/cli/pair.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/server/src/cli/pair.ts b/apps/server/src/cli/pair.ts index 4b563155c6bfe..2d45d45befeec 100644 --- a/apps/server/src/cli/pair.ts +++ b/apps/server/src/cli/pair.ts @@ -143,6 +143,15 @@ export class TailscaleServeFailedError extends Schema.TaggedError()( + "TailscaleOperatorRequiredError", + { cause: Schema.Defect() }, +) { + override get message(): string { + return "Tailscale refused the Serve config because this user is not its operator. Run `sudo tailscale set --operator=$USER` once, then run this command again."; + } +} + export class TailscaleServeTargetRefusedError extends Schema.TaggedError()( "TailscaleServeTargetRefusedError", { localHost: Schema.String }, @@ -425,6 +434,7 @@ const resolveTailscalePairingBase = Effect.fn("pair.resolveTailscalePairingBase" } // The probe above fails whenever this host cannot reach its own MagicDNS name, so the Serve // config, not the probe, decides whether the port is free. + const platform = yield* HostProcess.Platform; const holder = yield* readTailscaleServeRootHolder(input.servePort, { host: (localTarget.localHost ?? "127.0.0.1").replace(/^\[|\]$/gu, ""), port: localTarget.localPort, @@ -437,13 +447,18 @@ const resolveTailscalePairingBase = Effect.fn("pair.resolveTailscalePairingBase" servePort: input.servePort, ...(localTarget.localHost !== undefined ? { localHost: localTarget.localHost } : {}), }).pipe( - Effect.mapError((cause) => - cause._tag === "TailscaleCommandExitError" && - cause.stderrDiagnostic === "unsupported-target" && - localTarget.localHost !== undefined - ? new TailscaleServeTargetRefusedError({ localHost: localTarget.localHost }) - : new TailscaleServeFailedError({ servePort: input.servePort, cause }), - ), + Effect.mapError((cause) => { + const diagnostic = + cause._tag === "TailscaleCommandExitError" ? cause.stderrDiagnostic : undefined; + if (diagnostic === "unsupported-target" && localTarget.localHost !== undefined) { + return new TailscaleServeTargetRefusedError({ localHost: localTarget.localHost }); + } + // Only Linux tailscaled has an operator; elsewhere a denial needs another fix. + if (diagnostic === "permission-denied" && platform === "linux") { + return new TailscaleOperatorRequiredError({ cause }); + } + return new TailscaleServeFailedError({ servePort: input.servePort, cause }); + }), ); notes.push( `Tailscale Serve now maps ${baseUrl} to this server and persists across restarts. Remove it with \`tailscale serve --https=${String(input.servePort)} --set-path=/ off\`.`,