{"record":{"id":"18d67848ba365d0e","repo":"jackwener/OpenCLI","slug":"tiktok-studio-item-list-failed-statusmsg-sta","errorCode":null,"errorMessage":"TikTok Studio item_list failed: ${statusMsg || statusCode}","messagePattern":"TikTok Studio item_list failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/tiktok/creator-videos.js","lineNumber":122,"sourceCode":"function looksAuthFailure(message) {\n    return /\\b(auth|login|log in|permission|unauthori[sz]ed|forbidden)\\b/i.test(message);\n}\n\nfunction unwrapPayload(data) {\n    if (!data || typeof data !== 'object') {\n        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', {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/creator-videos.js#L104-L140","documentation":"When item_list returns a non-zero status_code whose message does NOT look like an auth problem, assertApiSuccess throws CommandExecutionError including the server's status_msg or code. This surfaces TikTok-side business errors (bad parameters, internal errors, account restrictions) rather than masking them.","triggerScenarios":"item_list responds with statusCode != 0 and status_msg such as 'rate limit exceeded', 'invalid params', or an internal error code — anything not matching the auth regex.","commonSituations":"Hammering the endpoint past rate limits; requesting a user whose videos are private/deleted; TikTok API incident; passing a user name the studio endpoint cannot resolve.","solutions":["Read the appended statusMsg/statusCode in the message to identify the server-side cause.","Back off and retry with exponential delay if the message suggests rate limiting.","Verify the target creator/user parameters are correct.","Check TikTok service status; retry later if it's a server-side error."],"exampleFix":"// before\nawait fetchCreatorVideosPage(...); // throws 'TikTok Studio item_list failed: rate limit exceeded'\n// after\ntry {\n  await fetchCreatorVideosPage(...);\n} catch (e) {\n  if (String(e.message).includes('failed:')) {\n    await sleep(5000); // back off before retry\n    await fetchCreatorVideosPage(...);\n  } else throw e;\n}","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:') && /rate|busy|limit/i.test(msg)) {\n    await sleep(5000 * attempt);\n    return listCreatorVideos(opts);\n  }\n  throw e;\n}","preventionTips":["Add exponential backoff for non-auth item_list failures.","Throttle request rate to stay under TikTok's limits.","Log the status_msg/statusCode embedded in the message for diagnosis.","Verify target creator/username parameters before blaming the API."],"tags":["api","tiktok","server-error","rate-limit"],"backgroundTag":"api-status-code-error","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}