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

  1. Inspect the submit endpoint response in the browser network tab — confirm HTTP 200 and the exact field name carrying the task id.
  2. If the field differs, align the check with the real contract (e.g. `submitResult?.data?.task_id`).
  3. Check the airag backend logs for why the task was rejected (quota, filter, missing model config).
  4. 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

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.