jeecgboot/JeecgBoot · error · Error
提交任务失败
Error message
提交任务失败
What it means
In `handleGenerate`, after `submitVideoTask` resolves the code requires the response to be truthy AND contain a `taskId`; otherwise it throws the server `message` or the generic `提交任务失败`. This protects the subsequent polling loop (`queryVideoTask(submitResult.taskId)`) from polling an undefined id.
Source
Thrown at jeecgboot-vue3/src/views/super/airag/aivideo2/AiVideo.vue:170
generating.value = true;
videoUrl.value = '';
errorMessage.value = '';
elapsedSeconds.value = 0;
statusText.value = '任务已提交,排队中...';
// 启动计时器
elapsedTimer = setInterval(() => {
elapsedSeconds.value++;
}, 1000);
// 提交任务
const submitResult = await submitVideoTask({
prompt: values.prompt.trim(),
category: activeCategory.value,
});
if (!submitResult || !submitResult.taskId) {
throw new Error(submitResult?.message || '提交任务失败');
}
statusText.value = '视频生成中...';
// 开始轮询
pollTimer = setInterval(async () => {
try {
const queryResult = await queryVideoTask(submitResult.taskId);
if (queryResult.status === 'SUCCESS') {
clearTimers();
generating.value = false;
videoUrl.value = queryResult.videoUrl;
createMessage.success('视频生成成功!');
} else if (queryResult.status === 'FAIL') {
clearTimers();
generating.value = false;
errorMessage.value = queryResult.message || '视频生成失败';
}View on GitHub (pinned to 96fb33f5ec)
Solutions
- Inspect the submit endpoint response in the browser network tab — confirm HTTP 200 and the exact field name carrying the task id.
- If the field differs, align the check with the real contract (e.g. `submitResult?.data?.task_id`).
- Check the airag backend logs for why the task was rejected (quota, filter, missing model config).
- Verify the bearer token is present (defHttp attaches it) and not expired.
Example fix
// before
if (!submitResult || !submitResult.taskId) {
throw new Error(submitResult?.message || '提交任务失败');
}
// after — surface the real response so the failure is diagnosable
if (!submitResult?.taskId) {
const reason = submitResult?.message || JSON.stringify(submitResult) || 'empty response';
throw new Error(`提交任务失败: ${reason}`);
} Defensive patterns
Strategy: validation
Validate before calling
// validate the submit response shape before relying on taskId
const submitResult = await submitVideoTask({ prompt: values.prompt.trim(), category: activeCategory.value });
const taskId = submitResult?.taskId ?? submitResult?.data?.task_id; // tolerant to either contract
if (!taskId) {
errorMessage.value = submitResult?.message || '提交任务失败';
return;
} Type guard
const isVideoTaskResult = (r: unknown): r is { taskId: string } =>
typeof r === 'object' && r !== null && typeof (r as any).taskId === 'string' && (r as any).taskId.length > 0; Try / catch
// keep the single outer try/catch in handleGenerate; just feed it a precise message
try {
const submitResult = await submitVideoTask(/* ... */);
if (!isVideoTaskResult(submitResult)) {
throw new Error(`提交任务失败: ${submitResult?.message || JSON.stringify(submitResult) || 'no taskId'}`);
}
// ...poll
} catch (error: any) {
clearTimers();
generating.value = false;
errorMessage.value = error?.message || '提交任务失败';
} Prevention
- Define and share a TypeScript interface for the submit response across FE/BE.
- Assert the response shape with a type guard before using taskId.
- Add an integration test that confirms the backend returns taskId on success.
- Log the raw submit response on failure so contract drift is visible.
When it happens
Trigger: `submitVideoTask` returns `null`/`undefined` (backend returned success with empty body), returns an object lacking `taskId`, or the HTTP layer normalized a non-200 into a falsy payload. Also fires when the backend replies `{ message: '...' }` with no `taskId` (quota exceeded, content filter, model not configured).
Common situations: The airag video backend is down or mis-configured; the prompt tripped content moderation; the API contract changed and `taskId` was renamed (e.g. `id`, `task_id`); the auth token expired so the interceptor returned an error object without `taskId`; rate-limit response.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/508b7d357411a08e.
Report an issue: GitHub.