{"record":{"id":"2850597d1eb6c45d","repo":"yikart/AiToEarn","slug":"error-285059","errorCode":null,"errorMessage":"网络繁忙，请稍后重试！","messagePattern":"网络繁忙，请稍后重试！","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"project/aitoearn-electron/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx","lineNumber":211,"sourceCode":"\n        await signInApi.createSignInRecord();\n        const err = () => {\n          setLoading(false);\n          message.error('网络繁忙，请稍后重试！');\n        };\n        usePubStroe.getState().clearVideoPubSaveData();\n        // 创建一级记录\n        const recordRes = await icpCreatePubRecord({\n          title: commonPubParams.title,\n          desc: commonPubParams.describe,\n          type: PubType.VIDEO,\n          timingTime: commonPubParams.timingTime,\n          videoPath: videoListChoose[0].video?.videoPath,\n          coverPath: videoListChoose[0].pubParams.cover?.imgPath,\n          commonCoverPath: commonPubParams.cover?.imgPath,\n        });\n        recordId.current = recordRes.id;\n        if (!recordRes) return err();\n\n        setPubProgressModuleOpen(true);\n        setLoading(true);\n\n        // 发布记录通知消息初始化\n        const initialNotice: NoticeItem = {\n          title:\n            [\n              ...new Set(\n                videoListChoose.map(\n                  (v) => AccountPlatInfoMap.get(v.account!.type)!.name,\n                ),\n              ),\n            ].join('、') + '发布任务',\n          time: recordRes.createTime!,\n          id: recordRes.id,\n          pub: {\n            status: PubStatus.UNPUBLISH,","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx#L193-L229","documentation":"In VideoPubSetModal, pubCore calls icpCreatePubRecord (video publish record) and immediately assigns recordRes.id, then checks !recordRes afterwards. If the IPC/backend record creation fails, err() shows the generic toast '网络繁忙，请稍后重试！'. Note the code order is fragile: recordRes.id is read before the falsy check, so a null result can also throw before err() is reached.","triggerScenarios":"icpCreatePubRecord returns falsy because the backend rejected video record creation: server unreachable, expired auth, missing videoPath/coverPath, or a backend validation/500 error on the video publish endpoint.","commonSituations":"Video file path invalid or not yet downloaded when publishing is confirmed; user session expired mid-flow; backend down during scheduled-publish configuration; race where cover hasn't been generated.","solutions":["Move the `recordId.current = recordRes.id` assignment AFTER the `if (!recordRes)` check to avoid a TypeError masking the toast","Inspect main-process logs for the real icpCreatePubRecord error","Re-login if the session/token expired; confirm backend health","Ensure videoPath and cover paths exist before opening the publish modal"],"exampleFix":"// before\nrecordId.current = recordRes.id;\nif (!recordRes) return err();\n// after\nif (!recordRes) return err();\nrecordId.current = recordRes.id;","handlingStrategy":"validation","validationCode":"// before confirming publish in the modal\nif (!videoListChoose[0]?.video?.videoPath) { message.error('视频路径无效'); return; }\nif (!videoListChoose[0]?.pubParams?.cover?.imgPath) { message.error('请设置封面'); return; }","typeGuard":"function isRecordCreated(r: unknown): r is { id: string } {\n  return typeof r === 'object' && r !== null && 'id' in r && typeof (r as any).id === 'string';\n}","tryCatchPattern":"const recordRes = await icpCreatePubRecord({ ... }).catch((e) => { console.error(e); return null; });\nif (!isRecordCreated(recordRes)) return err();\nrecordId.current = recordRes.id; // assign only after the guard","preventionTips":["Move recordRes.id access after the null check","Validate videoPath/cover exist before submitting","Keep the session fresh; re-authenticate on 401s","Surface backend error details in dev builds"],"tags":["electron","ipc","publish-record","null-check-order"],"backgroundTag":"publish-record-creation-failed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}