{"record":{"id":"385e965119a3ef2d","repo":"jackwener/OpenCLI","slug":"probe-detail","errorCode":null,"errorMessage":"${probe.detail}","messagePattern":"\\$\\{probe\\.detail\\}","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/12306/auth.js","lineNumber":40,"sourceCode":"      if (/login\\\\.html/.test(r.url)) {\n        return { kind: 'auth', detail: '12306 initMy12306Api redirected to login' };\n      }\n      const t = await r.text();\n      let d = null;\n      try { d = JSON.parse(t); } catch {}\n      if (!d || d.status === false || /未登录|登录超时|NotLogin/i.test(t)) {\n        return { kind: 'auth', detail: '12306 initMy12306Api returned NotLogin' };\n      }\n      const userName = d.data?.user_name || d.data?.userName || d.user_name || '';\n      if (!userName) {\n        return { kind: 'auth', detail: '12306 initMy12306Api 200 but no user_name surface' };\n      }\n      return { ok: true, user_name: String(userName) };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('12306.cn', probe.detail);\n  if (probe?.kind === 'exception') throw new CommandExecutionError(`12306 whoami failed: ${probe.detail}`);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected 12306 probe: ${JSON.stringify(probe)}`);\n  return { user_name: probe.user_name };\n}\n\nregisterSiteAuthCommands({\n  site: '12306',\n  domain: '12306.cn',\n  loginUrl: 'https://kyfw.12306.cn/otn/resources/login.html',\n  columns: ['user_name'],\n  quickCheck: has12306SessionCookie,\n  verify: verify12306Identity,\n  poll: async (page) => {\n    if (!await has12306SessionCookie(page)) {\n      throw new AuthRequiredError('12306.cn', 'Waiting for 12306 tk auth cookie');\n    }\n    return verify12306Identity(page);\n  },","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/12306/auth.js#L22-L58","documentation":"CommandExecutionError raised when the bookmarkFoldersSlice GraphQL call returns an error payload. The context note 'account may not have folder access' reflects that bookmark folders are a gated Twitter feature (originally Blue/premium), so many accounts receive an authorization error even while logged in.","triggerScenarios":"The authenticated account is not entitled to bookmark folders; the endpoint returns 403/404 for the feature; a stale queryId produces 404; transient 5xx from Twitter; rate limiting.","commonSituations":"Free accounts trying to use a premium-only feature; region/rollout gating where the feature isn't enabled yet; running an older CLI whose pinned/fetched queryId no longer matches the deployed GraphQL API.","solutions":["Confirm the account actually has bookmark-folder access (check x.com UI for folders under Bookmarks)","Retry after a short pause to rule out transient 5xx/429","Re-login to refresh the session and retry","Update the CLI so resolveTwitterQueryId picks up the current GraphQL queryId"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Feature-gated: check account entitlement before calling\n// (no local preflight possible beyond a successful login); detect via catch.","typeGuard":null,"tryCatchPattern":"try {\n  folders = await opencli('twitter bookmark-folders');\n} catch (e) {\n  if (/bookmarkFoldersSlice/.test(e.message)) {\n    if (/403/.test(e.message)) folders = null; // account lacks folder access — degrade gracefully\n    else throw e;\n  }\n}","preventionTips":["Confirm the account has the bookmark-folders feature in the x.com UI before scripting it","Add backoff for transient 5xx/429","Keep the CLI updated so resolveTwitterQueryId gets the current queryId","Treat this as a permission/entitlement problem, not a bug, when the account is a free tier"],"tags":["twitter","api-error","feature-gating","graphql"],"backgroundTag":"upstream-api-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}