{"record":{"id":"1115218efaebbe71","repo":"jackwener/OpenCLI","slug":"tiktok-studio-item-list-failed-statusmsg","errorCode":null,"errorMessage":"TikTok Studio item_list failed: ${statusMsg}","messagePattern":"TikTok Studio item_list failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/tiktok/creator-videos.js","lineNumber":128,"sourceCode":"        throw new CommandExecutionError('TikTok Studio item_list returned an empty response');\n    }\n    return data.data && typeof data.data === 'object' ? data.data : data;\n}\n\nfunction assertApiSuccess(data) {\n    const statusCode = data.status_code ?? data.statusCode;\n    const statusMsg = String(data.status_msg ?? data.statusMsg ?? '').trim();\n    if (statusCode !== undefined && Number(statusCode) !== 0) {\n        if (looksAuthFailure(statusMsg)) {\n            throw new AuthRequiredError('www.tiktok.com', `TikTok Studio item_list requires login: ${statusMsg || statusCode}`);\n        }\n        throw new CommandExecutionError(`TikTok Studio item_list failed: ${statusMsg || statusCode}`);\n    }\n    if (statusMsg && !/^(success|ok)$/i.test(statusMsg)) {\n        if (looksAuthFailure(statusMsg)) {\n            throw new AuthRequiredError('www.tiktok.com', `TikTok Studio item_list requires login: ${statusMsg}`);\n        }\n        throw new CommandExecutionError(`TikTok Studio item_list failed: ${statusMsg}`);\n    }\n}\n\nfunction normalizeNumber(value) {\n    const n = Number(value);\n    return Number.isFinite(n) ? n : 0;\n}\n\nfunction formatDate(value) {\n    const seconds = Number(value);\n    if (!Number.isFinite(seconds) || seconds <= 0) return '';\n    return new Date(seconds * 1000).toLocaleString('zh-CN', {\n        timeZone: 'Asia/Shanghai',\n        hour12: false,\n    });\n}\n\nfunction extractUsername(item) {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/creator-videos.js#L110-L146","documentation":"Final guard in assertApiSuccess: status_code is zero/absent but status_msg is a non-success, non-auth string, so the library throws CommandExecutionError with the raw message. It ensures any unexpected TikTok status message is surfaced instead of being treated as success.","triggerScenarios":"item_list returns statusCode 0 (or missing) with status_msg like 'data not ready', 'server busy', or any text not matching /^(success|ok)$/i and not matching the auth regex.","commonSituations":"TikTok returning soft-degraded responses under load; new/unusual status messages introduced by TikTok API changes; edge cases like 'success with warnings' phrasing the library treats as failure.","solutions":["Read the status_msg appended to the error for the server's explanation and retry if transient.","Add backoff/retry for messages like 'server busy' or 'data not ready'.","If the message is actually benign, update looksAuthFailure/the success regex in the library to recognize it.","Capture the raw response payload to report/inspect when the message is unclear."],"exampleFix":"// before\nif (statusMsg && !/^(success|ok)$/i.test(statusMsg)) { throw ... }\n// after\nif (statusMsg && !/^(success|ok|success_with_warning)$/i.test(statusMsg)) { throw ... } // recognize benign new statuses","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const videos = await listCreatorVideos(opts);\n} catch (e) {\n  const msg = String(e.message);\n  if (msg.includes('item_list failed:') && /busy|not ready|try again/i.test(msg)) {\n    await sleep(3000);\n    return listCreatorVideos(opts);\n  }\n  throw e;\n}","preventionTips":["Retry transient-sounding status messages with backoff.","Log the full raw payload alongside the thrown message for triage.","Keep the library's success/status regexes updated as TikTok adds new status texts.","Treat unknown non-success status messages as failures, never silently ignore them."],"tags":["api","tiktok","server-error","status-message"],"backgroundTag":"api-status-code-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}