{"record":{"id":"978df78f87b96402","repo":"ruvnet/RuView","slug":"status-resp-status","errorCode":null,"errorMessage":"status ${resp.status}","messagePattern":"status (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"ui/utils/quick-settings.js","lineNumber":295,"sourceCode":"// cookie. An XHR would follow the redirect invisibly and land nowhere useful.\nexport async function refreshSignInPanel(root = document) {\n  const status = root.querySelector('#qs-signin-status');\n  const signIn = root.querySelector('#qs-signin');\n  const signOut = root.querySelector('#qs-signout');\n  if (!status || !signIn || !signOut) return null;\n\n  let info;\n  try {\n    const resp = await fetch('/oauth/status', { credentials: 'same-origin' });\n    // 404 = a server predating ADR-271. Say so plainly rather than offering a\n    // button that will 404.\n    if (resp.status === 404) {\n      status.textContent = 'This server does not support Cognitum sign-in.';\n      signIn.hidden = true;\n      signOut.hidden = true;\n      return null;\n    }\n    if (!resp.ok) throw new Error(`status ${resp.status}`);\n    info = await resp.json();\n  } catch (err) {\n    status.textContent = `Could not reach the server (${err.message}).`;\n    signIn.hidden = true;\n    signOut.hidden = true;\n    return null;\n  }\n\n  if (info.signed_in) {\n    status.textContent = `Signed in${info.account ? ` as ${info.account}` : ''}${\n      info.scope ? ` - ${info.scope}` : ''\n    }`;\n    signIn.hidden = true;\n    signOut.hidden = false;\n  } else if (info.browser_signin) {\n    status.textContent = info.auth_required\n      ? 'This server requires sign-in.'\n      : 'Optional: sign in to use your Cognitum account.';","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/ui/utils/quick-settings.js#L277-L313","documentation":"Thrown by the OAuth status probe in ui/utils/quick-settings.js: it fetches GET /oauth/status with same-origin credentials and throws `status ${resp.status}` for any non-OK response other than 404 (404 is handled explicitly as 'server predating ADR-271'). The throw is immediately caught by the surrounding try/catch and rendered as 'Could not reach the server', so it represents any HTTP failure of the Cognitum sign-in status endpoint other than not-implemented.","triggerScenarios":"/oauth/status returning 500/502/503/504 because the auth backend or its upstream is down; a reverse proxy not routing /oauth/* to the API server; a 401/400 from a misconfigured OAuth client; a gateway timeout behind nginx/Caddy.","commonSituations":"Reverse proxy config missing the /oauth/ location block; OAuth client id/secret unset so the endpoint errors; API server mid-restart; corporate proxy intercepting same-origin requests.","solutions":["Check the API server implements /oauth/status per ADR-271 and that its OAuth client settings (client id/secret/redirect) are configured","Open the network tab and read the response body of the failing /oauth/status call to find the real server-side error","Fix reverse-proxy routing so /oauth/* reaches the API process","If the deployment intentionally predates ADR-271, expect 404 and the friendly 'does not support Cognitum sign-in' path instead"],"exampleFix":"// before\nif (!resp.ok) throw new Error(`status ${resp.status}`);\n\n// after: keep the plain message but log the body for diagnosis\nif (!resp.ok) {\n  const body = await resp.text().catch(() => '');\n  console.warn('/oauth/status failed', resp.status, body);\n  throw new Error(`status ${resp.status}`);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const resp = await fetch('/oauth/status', { credentials: 'same-origin' });\n  if (resp.status === 404) {\n    // server predates ADR-271: hide sign-in UI, not an error\n  } else if (resp.status >= 500) {\n    // server-side failure: retry later, show server error state\n  } else if (!resp.ok) {\n    throw new Error(`status ${resp.status}`);\n  }\n} catch (err) {\n  // network-level failure (offline, DNS, proxy): show offline state\n  status.textContent = `Could not reach the server (${err.message}).`;\n}","preventionTips":["Smoke-test /oauth/status after every proxy or server upgrade","Keep the 404 special-case in sync with the minimum supported server version","Log the response body on non-OK statuses so misconfiguration is diagnosable from the client"],"tags":["http","oauth","ui","status-check"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}