Repository navigation
Description
Summary
OAuth clients receive an empty error response when client registration metadata has an invalid JSON type. The server should return a JSON registration error so clients can identify and explain the rejected metadata. A disposable HTTP harness reproduced the empty response, while valid registration and a disallowed redirect URI returned their expected responses.
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Use a checkout of the Version below with its lockfile dependencies installed and the repository's Node runtime available.
- Save the script below outside the checkout and run
node repro.mjs /path/to/t3code. - Observe the successful HTTP 201 registration control and the HTTP 400 JSON
invalid_redirect_uricontrol, followed by empty HTTP 400 responses for invalid metadata types.
The final script reproduced both failing inputs in one run. During harness construction, an initial module-resolution failure, an assumption that all responses were JSON, and a syntax error in that harness produced inconclusive attempts; they are corrected in the exact script below. No second confirmation run was performed after the completed reproduction.
Save this as repro.mjs and run node repro.mjs /path/to/t3code. It requires the checkout's installed dependencies and Node runtime, prints the Node, T3, and Effect versions, and calls the production OAuth HTTP group through Effect's in-process web handler. It creates a disposable HOME, TMPDIR, T3 state directory, and in-memory database, uses test settings and policy with a disconnected cloud-link mock, and disposes its routes and scratch files. It opens no network listener or real authorization flow and changes no checkout files. Exit 1 means the defect reproduced, 0 means both errors meet the expected registration response contract, and 2 means setup or a control failed.
Reproduction script: repro.mjs
import { mkdtemp, mkdir, rm, readFile } from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
const root = path.resolve(process.argv[2] ?? '.');
const scratch = await mkdtemp(path.join(os.tmpdir(), 't3-registration-repro-'));
let status = 2;
try {
for (const name of ['home', 'tmp', 'state']) await mkdir(path.join(scratch, name));
process.env.HOME = path.join(scratch, 'home');
process.env.TMPDIR = path.join(scratch, 'tmp');
process.env.T3CODE_HOME = path.join(scratch, 'state');
console.log(`Node ${process.version}; ${process.platform} ${process.arch}`);
const require = createRequire(path.join(root, 'apps/server/package.json'));
const pkg = async (name) => import(pathToFileURL(require.resolve(name)).href);
const src = async (name) => import(pathToFileURL(path.join(root, 'apps/server/src', name)).href);
const Effect = await pkg('effect/Effect');
const Layer = await pkg('effect/Layer');
const Context = await pkg('effect/Context');
const SecureRandom = await pkg('effect/crypto/SecureRandom');
const HttpRouter = await pkg('effect/http/HttpRouter');
const HttpApi = await pkg('effect/http-api/HttpApi');
const HttpApiBuilder = await pkg('effect/http-api/HttpApiBuilder');
const HttpPlatform = await pkg('effect/http/HttpPlatform');
const Etag = await pkg('effect/http/Etag');
const NodeServices = await pkg('@effect/platform-node/NodeServices');
const NodeCrypto = await pkg('@effect/platform-node/NodeCrypto');
const { EnvironmentHttpApi } = await import(pathToFileURL(path.join(root, 'packages/contracts/src/index.ts')).href);
const ServerConfig = await src('config.ts');
const EnvironmentAuth = await src('auth/EnvironmentAuth.ts');
const ServerSecretStore = await src('auth/ServerSecretStore.ts');
const ServerEnvironment = await src('environment/ServerEnvironment.ts');
const ServerSettings = await src('serverSettings.ts');
const Sqlite = await src('persistence/Sqlite.ts');
const ManagedPolicy = await src('policy/ManagedPolicy.ts');
const McpOAuth = await src('auth/McpOAuth.ts');
const McpOAuthHttp = await src('auth/mcpOAuthHttp.ts');
const CloudLink = await src('cloud/CloudLink.ts');
const effectInfo = JSON.parse(await readFile(path.join(path.dirname(require.resolve('effect/package.json')), 'package.json'), 'utf8'));
console.log(`T3 ${JSON.parse(await readFile(path.join(root, 'apps/server/package.json'), 'utf8')).version}; effect ${effectInfo.version}`);
const config = ServerConfig.layerTest(root, path.join(scratch, 'state'));
const auth = EnvironmentAuth.layer.pipe(
Layer.provide(ManagedPolicy.layerTest()),
Layer.provide(Sqlite.layerMemory),
Layer.provideMerge(ServerSecretStore.layer),
Layer.provideMerge(ServerEnvironment.layerIdentity),
Layer.provide(config),
);
const api = HttpApi.make('environment').add(EnvironmentHttpApi.groups.mcpOAuth);
const routes = HttpApiBuilder.layer(api).pipe(
Layer.provide(McpOAuthHttp.layer.pipe(
Layer.provide(McpOAuth.layer),
Layer.provide(ServerSettings.layerTest({ linkedEnvironmentsEnabled: true })),
Layer.provide(Layer.mock(CloudLink.CloudLink)({ linkState: () => Effect.succeed({ linked: false, cloudUserId: null, relayUrl: null, relayIssuer: null, publishAgentActivity: false }) })),
)),
Layer.provideMerge(auth), Layer.provide(config),
Layer.provideMerge(HttpPlatform.layer.pipe(
Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
Layer.provideMerge(Etag.layerWeak),
)),
Layer.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
);
await Effect.runPromise(Effect.gen(function* () {
const random = yield* SecureRandom.SecureRandom;
const context = Context.make(SecureRandom.SecureRandom, random);
const web = HttpRouter.toWebHandler(routes, { disableLogger: true });
try {
const post = async (body) => {
const response = await web.handler(new Request('http://localhost/oauth/mcp/register', {
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body),
}), context);
const text = await response.text();
let decoded;
try { decoded = JSON.parse(text); } catch { decoded = text; }
return { status: response.status, contentType: response.headers.get('content-type'), body: decoded };
};
const normal = yield* Effect.promise(() => post({ client_name: 'Registration test', redirect_uris: ['https://client.example/callback'], token_endpoint_auth_method: 'none' }));
console.log(`control: status=${normal.status}; content-type=${normal.contentType}; metadata=${JSON.stringify({ ...normal.body, client_id: typeof normal.body.client_id === 'string' ? '[generated client ID omitted]' : normal.body.client_id })}`);
if (normal.status !== 201 || typeof normal.body.client_id !== 'string' || normal.body.token_endpoint_auth_method !== 'none') throw new Error('Registration control failed');
const invalidUri = yield* Effect.promise(() => post({ redirect_uris: ['ftp://client.example/callback'] }));
console.log(`URI error control: ${JSON.stringify(invalidUri)}`);
if (invalidUri.status !== 400 || invalidUri.body.error !== 'invalid_redirect_uri') throw new Error('URI error control failed');
const invalidMetadata = yield* Effect.promise(() => post({ client_name: 42, redirect_uris: ['https://client.example/callback'] }));
console.log(`invalid metadata: ${JSON.stringify(invalidMetadata)}`);
const invalidArray = yield* Effect.promise(() => post({ redirect_uris: 'https://client.example/callback' }));
console.log(`invalid redirect array: ${JSON.stringify(invalidArray)}`);
const validOAuthError = (r) => r.status === 400 && r.contentType?.startsWith('application/json') && ['invalid_client_metadata', 'invalid_redirect_uri'].includes(r.body.error);
status = validOAuthError(invalidMetadata) && validOAuthError(invalidArray) ? 0 : 1;
} finally {
yield* Effect.promise(() => web.dispose());
}
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))));
} catch (error) {
console.error(`Setup/control failed: ${error.message}`);
status = 2;
} finally {
await rm(scratch, { recursive: true, force: true });
}
console.log(status === 0 ? 'RESULT: expected behavior' : status === 1 ? 'RESULT: defect reproduced' : 'RESULT: inconclusive');
process.exitCode = status;Expected behavior
RFC 7591 §3.2.2 requires an unsuccessful registration response to use HTTP 400 with an application/json body containing a required error string. It defines invalid_client_metadata for a rejected invalid client metadata value and invalid_redirect_uri for invalid redirect URI values. A metadata type error should therefore produce a JSON registration error instead of an empty generic HTTP error. The valid registration control must continue returning HTTP 201 with registered client metadata.
Actual behavior
POST /oauth/mcp/register with Content-Type: application/json, a valid HTTPS callback, and client_name: 42 returns HTTP 400, no Content-Type header, and an empty body. A string-valued redirect_uris produces the same empty error. These are syntactically valid JSON registration requests whose metadata types are invalid; the error is not a JSON registration response.
Impact
Minor bug or occasional failure
Impact: P2 - Registration clients lose the required machine-readable rejection reason for malformed metadata; successful registration remains available, and correcting the payload is a practical workaround demonstrated by the control.
The observed scope is the production registration endpoint's request-schema rejection path, including numeric client_name and non-array redirect_uris. The failure occurred for both tested malformed inputs in the completed harness run. No external client's UI behavior or live deployment was tested, and no claim is made that this explains a particular hosted client's authentication failure.
Version or commit
T3 server package 0.1.9, commit 59e64eef881632a23f89c4138bcf37f23d92bf93.
Environment
Node v26.12.1, macOS darwin arm64, pinned [email protected]. The reproduction uses Node's native TypeScript support and the installed production modules, with no test runner or build.
Interface: API: POST /oauth/mcp/register for outside MCP clients. Earliest failure stage: Input parsing or validation.
Logs or stack traces
Evidence
Relevant lines from the completed script run are below; generated client identifiers are omitted by the script itself. Database migration progress is omitted here because it contains no failure evidence.
Node v26.12.1; darwin arm64
T3 0.1.9; effect 4.1.3
control: status=201; content-type=application/json; metadata={"client_id":"[generated client ID omitted]","client_name":"Registration test","redirect_uris":["https://client.example/callback"],"grant_types":["authorization_code"],"response_types":["code"],"token_endpoint_auth_method":"none"}
URI error control: {"status":400,"contentType":"application/json","body":{"error":"invalid_redirect_uri","error_description":"Redirect URIs must be https, or http on localhost, 127.0.0.1 or [::1]."}}
invalid metadata: {"status":400,"contentType":null,"body":""}
invalid redirect array: {"status":400,"contentType":null,"body":""}
RESULT: defect reproduced
The T3 request schema requires string-valued client_name and array-valued redirect_uris in packages/contracts/src/auth.ts#L493-L498, and the registration route attaches that payload schema in packages/contracts/src/environmentHttp.ts#L649-L654. T3's normal service errors have the OAuth error fields in packages/contracts/src/auth.ts#L511-L518.
Source evidence: the request-schema rejection occurs before the registration handler at apps/server/src/auth/mcpOAuthHttp.ts#L103-L117. The pinned Effect HTTP API builder wraps decoding failures as HttpApiSchemaError, whose documented default response is empty HTTP 400. This is the framework's generic request behavior; the missing OAuth-specific registration error response belongs to T3's endpoint integration, rather than Effect's MCP protocol adapters.
Restoration check
The same malformed registration requests return HTTP 400 with a JSON object containing the applicable registration error string, while the valid registration and invalid-URI controls continue to pass. The included script is the restoration check and exits 0 when these conditions hold.
Workaround
Send the metadata with the correct JSON types, as demonstrated by the successful registration control. This avoids the failing input; it does not restore the missing error response for rejected registrations.
References
- Gemini Spark MCP setup fails during automatic OAuth client registration #31308 — concerns rejecting a client's redirect URI count; this report concerns the missing OAuth error envelope when a metadata type is rejected, with a single callback sufficient to reproduce it.
- fix(server): Gemini Spark can register its six MCP OAuth redirect URIs #31319 — changes redirect-count and client-ID length bounds; it does not cover malformed metadata error responses.
- MCP OAuth compatibility question: Grok Bot stops after successful DCR and never opens authorization #31926 — investigated a client stopping after successful registration; both errors here happen during registration, and no causal connection to that client is claimed.
Activity
maria-rcks commentedon Nov 15, 2026
Note
Written by
claude-fable-5-2on behalf of MariaClosing: this account is denounced in
.github/VOUCHED.tdfor filing automated issues faster than maintainers can triage them. A fix PR that links this issue is not affected by this close.