{"record":{"id":"0d334922973143ea","repo":"iflytek/astron-agent","slug":"workflow-promptdebugger-importresponseinvalid","errorCode":null,"errorMessage":"workflow.promptDebugger.importResponseInvalid","messagePattern":"workflow\\.promptDebugger\\.importResponseInvalid","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console/frontend/src/components/make-creation/components/WorkflowImportModal.tsx","lineNumber":468,"sourceCode":"\n  const handleOk = () => {\n    const file = uploadList[0]?.file;\n    if (!file || requestInFlightRef.current) return;\n    const requestGeneration = ++requestGenerationRef.current;\n    requestInFlightRef.current = true;\n    setLoading(true);\n    workflowImport({\n      file,\n    })\n      .then((value: unknown) => {\n        if (\n          !mountedRef.current ||\n          requestGeneration !== requestGenerationRef.current\n        )\n          return;\n        const result = normalizeWorkflowImportResult(value);\n        if (!result) {\n          throw new Error(\n            i18next.t('workflow.promptDebugger.importResponseInvalid')\n          );\n        }\n        // Older servers return only a Workflow and preserve the original\n        // behaviour.  A report is shown inline so users can review unresolved\n        // references before opening the canvas.\n        if (result.report) {\n          setImportResult(result);\n          return;\n        }\n        openImportedCanvas(result, requestGeneration);\n      })\n      .catch((error: unknown) => {\n        if (\n          !mountedRef.current ||\n          requestGeneration !== requestGenerationRef.current\n        )\n          return;","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/frontend/src/components/make-creation/components/WorkflowImportModal.tsx#L450-L486","documentation":"handleOk in WorkflowImportModal throws 'workflow.promptDebugger.importResponseInvalid' when normalizeWorkflowImportResult(value) returns falsy — the server's import response could not be interpreted as a valid workflow import payload.","triggerScenarios":"The import API resolves with a value that normalizeWorkflowImportResult cannot parse (missing Workflow object, wrong shape, null data), or the request generation/mount check passed but the payload is stale/incompatible.","commonSituations":"Older or newer backend returning a response schema the frontend doesn't expect, uploading a file the server accepted but returned empty/partial data for, network proxy stripping the response body.","solutions":["Log/inspect the raw import response and compare with what normalizeWorkflowImportResult expects.","Check frontend/backend version alignment for the import API schema.","Re-export the workflow file and retry the import.","Add a unit test for normalizeWorkflowImportResult with the actual payload shape."],"exampleFix":"// before\nconst result = normalizeWorkflowImportResult(value);\nif (!result) { throw new Error(t('workflow.promptDebugger.importResponseInvalid')); }\n// after\nconsole.debug('import raw response', value);\nconst result = normalizeWorkflowImportResult(value);\nif (!result) { throw new Error(t('workflow.promptDebugger.importResponseInvalid')); }","handlingStrategy":"type-guard","validationCode":"function isImportPayload(v: unknown): v is WorkflowImportPayload {\n  return !!v && typeof v === 'object' && 'workflow' in (v as any);\n}","typeGuard":"function hasWorkflow(v: unknown): v is { workflow: Record<string, unknown> } {\n  return typeof v === 'object' && v !== null && 'workflow' in v;\n}","tryCatchPattern":"try {\n  await importWorkflow(file);\n} catch (e) {\n  if (e.message.includes('importResponseInvalid')) {\n    message.error(t('workflow.promptDebugger.importResponseInvalid'));\n  } else { throw e; }\n}","preventionTips":["Add schema validation (zod) on import responses.","Keep import API contract tests between frontend and backend.","Log raw payloads on parse failure for diagnosis."],"tags":["frontend","react","workflow","response-shape"],"backgroundTag":"unexpected-response-shape","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}