earendil-works/pi · error

Internal error

Error message

Internal error

What it means

Sentinel text for the generic catch branch of the callback server's request handler: URL parsing or response writing threw unexpectedly. The browser gets a 500-style error page while the outer try prevents the HTTP server from crashing, and the OAuth wait loop continues until timeout since no code was delivered.

Solutions

  1. An internal OAuth error occurred; retry and check the logs for details.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/ai/src/auth/oauth/anthropic.ts:148 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/4caeb4a76c2fee6f. Report an issue: GitHub.

Appendix: source

Thrown at packages/ai/src/auth/oauth/anthropic.ts:148

				}

				if (!code || !state) {
					res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
					res.end(oauthErrorHtml("Missing code or state parameter."));
					return;
				}

				if (state !== expectedState) {
					res.writeHead(400, { "Content-Type": "text/html; charset=utf-8" });
					res.end(oauthErrorHtml("State mismatch."));
					return;
				}

				res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
				res.end(oauthSuccessHtml("Anthropic authentication completed. You can close this window."));
				settleWait?.({ code, state });
			} catch {
				res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
				res.end("Internal error");
			}
		});

		server.on("error", (err) => {
			reject(err);
		});

		server.listen(CALLBACK_PORT, CALLBACK_HOST, () => {
			resolve({
				server,
				redirectUri: REDIRECT_URI,
				cancelWait: () => {
					settleWait?.(null);
				},
				waitForCode: () => waitForCodePromise,
			});
		});

View on GitHub (pinned to 4af9d21d3b)