{"record":{"id":"9bdccb9ffe5f3656","repo":"musistudio/claude-code-router","slug":"zcode-profiles-can-only-open-the-app-agent-argume","errorCode":null,"errorMessage":"ZCode profiles can only open the app; agent arguments are not supported.","messagePattern":"ZCode profiles can only open the app; agent arguments are not supported\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/cli.ts","lineNumber":122,"sourceCode":"    await runWebServer(options);\n    return;\n  }\n\n  const profileOptions = options as ProfileCliOptions;\n  if (profileOptions.help || !profileOptions.profileRef) {\n    printHelp(profileOptions.help ? 0 : 2);\n    return;\n  }\n\n  const configDir = CONFIGDIR;\n  const config = await loadAppConfig();\n  assertAvailableGatewayModels(config);\n  await applyProfileConfig(config);\n  const profile = findProfileForOpen(config, profileOptions.profileRef);\n  const surface = profileOptions.surface ?? defaultProfileOpenSurface(profile);\n  const resolvedSurface = resolveProfileOpenSurface(profile, surface);\n  if (profile.agent === \"zcode\" && profileOptions.agentArgs.length > 0) {\n    throw new Error(\"ZCode profiles can only open the app; agent arguments are not supported.\");\n  }\n  if (profile.agent === \"claude-design\") {\n    throw new Error(\"Claude Design profiles can only be opened from CCR Desktop.\");\n  }\n  if (profile.agent === \"claude-code\" && resolvedSurface === \"app\" && profileOptions.agentArgs.length > 0) {\n    throw new Error(\"Claude App profiles do not support agent arguments.\");\n  }\n  if (profile.agent === \"codex\" && resolvedSurface === \"app\" && profileOptions.agentArgs.length === 0) {\n    const state = await startService({\n      command: \"start\",\n      daemonChild: false,\n      ensureGatewayRunning: true,\n      help: false,\n      open: false,\n      profileManaged: false,\n      startGateway: true\n    });\n    const opened = await callServiceRpc<ProfileOpenResult>(state, \"openProfile\", [{ profileId: profile.id, surface: \"app\" }], 30_000);","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/cli/src/cli.ts#L104-L140","documentation":"Thrown by parseWebContentFetchResult when the provider's account endpoint responds 2xx but the Content-Type (or body sniffing) does not look like JSON. This is part of the OAuth/account-linking flow where an expected JSON account info endpoint instead returns HTML or another content type.","triggerScenarios":"Calling the account endpoint via createProviderAccountWebContentFetchHandler, the HTTP request succeeds (result.ok), but responseLooksJson() fails: contentType lacks 'json' and the body doesn't parse/sniff as JSON (e.g. text/html login page, plain text, empty body).","commonSituations":"Endpoint URL misconfigured to a human-facing page; a captive portal or reverse proxy serving an HTML error/consent page; the provider's account URL requires session cookies the fetch doesn't carry; server returns XML or plain text instead of JSON.","solutions":["Verify the account endpoint URL actually returns JSON (curl -i it and check Content-Type)","If a proxy/portal intercepts the request, fix network config or add required auth headers/cookies","If the endpoint legitimately returns non-JSON, correct the configured account URL in the provider settings","Check response body via readableResponseSnippet path/logging to see what was actually returned (HTML login page, XML, empty)"],"exampleFix":"// before\naccountUrl: \"https://provider.example.com/account\" // returns HTML\n// after\naccountUrl: \"https://provider.example.com/api/user\" // returns application/json","handlingStrategy":"try-catch","validationCode":"const looksJson = (ct?: string, text?: string) =>\n  (ct ?? '').toLowerCase().includes('json') || /^\\s*[\\[{]/.test(text ?? '');\n\nif (!result.ok || !looksJson(result.contentType, result.text)) {\n  // fall back to UI-driven account linking instead of parsing\n}","typeGuard":"function isJsonFetchResult(result: FetchResult): boolean {\n  return result.ok && responseLooksJson(result.contentType ?? '',\n    typeof result.text === 'string' ? result.text : '');\n}","tryCatchPattern":"try {\n  const data = await parseWebContentFetchResult(result);\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('Account endpoint returned non-JSON')) {\n    // endpoint served HTML/text: guide user to manual account entry\n  } else { throw error; }\n}","preventionTips":["Validate Content-Type before parsing account endpoint responses","Pre-flight the account URL with a HEAD/GET check during provider add","Log the content type and a body snippet whenever this fails to identify portal/proxy pages"],"tags":["http","content-type","json","account-linking","electron"],"backgroundTag":"unexpected-content-type","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}