{"record":{"id":"32a4623187e6a243","repo":"jackwener/OpenCLI","slug":"waiting-for-12306-tk-auth-cookie","errorCode":null,"errorMessage":"Waiting for 12306 tk auth cookie","messagePattern":"Waiting for 12306 tk auth cookie","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/12306/auth.js","lineNumber":55,"sourceCode":"      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  },\n});\n","sourceCodeStart":37,"sourceCodeEnd":60,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/12306/auth.js#L37-L60","documentation":"CommandExecutionError thrown when `twitter bookmark` completed without an unconfirmed write (so no timeout ambiguity) but result.ok was false — the in-page script caught an exception (e.g. button not found, click rejected) and returned it as result.message. The remediation hint 'Nothing changed' tells the user no state was modified, so a retry is safe.","triggerScenarios":"The bookmark button wasn't found on the rendered page (page didn't finish loading, tweet deleted/protected, logged-out view), the click threw, or an unexpected dialog/overlay intercepted the action.","commonSituations":"Deleted or private/protected tweets; rate-limited or partially loaded page; Twitter UI change moving the bookmark button's data-testid; session in a weird logged-out state without triggering the ct0 check path.","solutions":["Read result.message in the error text to see the underlying in-page exception","Open the tweet URL in the browser and verify the tweet exists and is bookmarkable","Reload the page/session (re-login if needed) and retry the command","If the button selector keeps failing after a reload, update or file an issue against the CLI — the UI testid likely changed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the tweet is publicly viewable before bookmarking\nconst res = await fetch(tweetUrl, { method: 'HEAD' });\nif (!res.ok) throw new Error(`Tweet unavailable: HTTP ${res.status}`);","typeGuard":"function isActionableFailure(r) { return r && typeof r === 'object' && r.ok === false && r.unconfirmed !== true; }","tryCatchPattern":"try {\n  await opencli('twitter bookmark', url);\n} catch (e) {\n  if (/Nothing changed/.test(e.message)) {\n    // safe to retry after checking the tweet exists and the page loads\n    await reloadAndVerify(tweetUrl);\n    await opencli('twitter bookmark', url);\n  }\n}","preventionTips":["Validate the tweet URL resolves and isn't deleted/protected before calling","Ensure the page is fully loaded (wait for primaryColumn) before actions","Read the embedded result.message to identify the DOM failure","Update the CLI when Twitter changes button data-testids"],"tags":["twitter","browser-automation","command-failed","dom-selector"],"backgroundTag":"browser-automation-click-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}