{"record":{"id":"6c89ceebe482679a","repo":"jackwener/OpenCLI","slug":"unexpected-suno-probe-json-stringify-probe","errorCode":null,"errorMessage":"Unexpected Suno probe: ${JSON.stringify(probe)}","messagePattern":"Unexpected Suno probe: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/suno/auth.js","lineNumber":46,"sourceCode":"      const d = await r.json();\n      const sessions = d?.response?.sessions || [];\n      if (!Array.isArray(sessions) || sessions.length === 0) {\n        return { kind: 'auth', detail: 'clerk.suno.com sessions=[] — anonymous' };\n      }\n      const active = sessions.find(s => s.status === 'active') || sessions[0];\n      const user = active?.user;\n      if (!user?.id) {\n        return { kind: 'auth', detail: 'clerk.suno.com session present but no user.id — stale session' };\n      }\n      return { ok: true, user_id: String(user.id), name: String(user.username || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('suno.com', probe.detail);\n  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from clerk.suno.com`);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`Suno whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Suno probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'suno',\n  domain: 'suno.com',\n  loginUrl: 'https://suno.com/?sign-in=true',\n  columns: ['user_id', 'name'],\n  quickCheck: hasSunoClerkCookie,\n  verify: verifySunoIdentity,\n  poll: async (page) => {\n    if (!await hasSunoClerkCookie(page)) {\n      throw new AuthRequiredError('suno.com', 'Waiting for Suno Clerk __session/__client cookie');\n    }\n    return verifySunoIdentity(page);\n  },\n});\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/suno/auth.js#L28-L64","documentation":"After all known probe outcomes (auth/http/exception) are handled, a probe result that is neither ok nor one of those kinds means the in-page script returned something unexpected (undefined, shape drift after a Clerk/Suno API change). verifySunoIdentity throws a CommandExecutionError embedding the JSON of the probe for diagnosis.","triggerScenarios":"page.evaluate returns null/undefined (serialization failure, page torn down) or Clerk's /v1/client response shape changed so the probe returns an unrecognized object without `kind`.","commonSituations":"Clerk API version bump (the probe pins _clerk_js_version=5) changing response fields; evaluate result lost because the browser page closed; middleware returning an unexpected redirect body.","solutions":["Inspect the JSON in the message — it shows the actual probe shape","Check if Clerk's /v1/client response schema changed and update the probe in clis/suno/auth.js","Re-run after ensuring the browser page stays open for the duration of the command","Pin/update _clerk_js_version to match Suno's current Clerk build"],"exampleFix":"// before\nif (!probe?.ok) throw new CommandExecutionError(`Unexpected Suno probe: ${JSON.stringify(probe)}`);\n// after — tolerate missing sessions field shape drift\nconst sessions = d?.response?.sessions ?? d?.sessions ?? [];\nif (!sessions.length) return { kind: 'auth', detail: 'clerk.suno.com sessions=[] — anonymous' };","handlingStrategy":"type-guard","validationCode":"// Detect an unusable probe result before depending on it\nif (!probe || typeof probe !== 'object' || (!('ok' in probe) && !('kind' in probe))) {\n  throw new Error('Clerk probe returned no recognizable shape: ' + JSON.stringify(probe));\n}","typeGuard":"function isProbeResult(p) {\n  return p != null && typeof p === 'object' &&\n    (p.ok === true || ['auth','http','exception'].includes(p.kind));\n}","tryCatchPattern":"try {\n  await cli('suno', 'whoami');\n} catch (e) {\n  if (/Unexpected Suno probe/.test(e.message)) {\n    console.error('Clerk API shape may have changed:', e.message); // report, don't auto-retry\n  }\n  throw e;\n}","preventionTips":["Pin and periodically update the _clerk_js_version probe parameter to match Suno's current build","Keep the browser page open for the whole command so evaluate results aren't lost","Log the embedded probe JSON when this fires to track Clerk schema drift","Wrap Clerk response parsing defensively (optional chaining, defaults)"],"tags":["api-change","clerk","suno","browser"],"backgroundTag":"unexpected-response-shape","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}