{"record":{"id":"d61efc6206c1b5fd","repo":"langgenius/dify","slug":"reconnect-stream-body-missing","errorCode":null,"errorMessage":"reconnect stream body missing","messagePattern":"reconnect stream body missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/api/app-run.ts","lineNumber":99,"sourceCode":"    })\n  }\n\n  async reconnectStream(\n    appId: string,\n    workflowRunId: string,\n    opts: StreamOptions = {},\n  ): Promise<AsyncIterable<SseEvent>> {\n    const url = `apps/${encodeURIComponent(appId)}/tasks/${encodeURIComponent(workflowRunId)}/events`\n    const res = await this.http.stream(url, {\n      searchParams: {\n        include_state_snapshot: opts.includeStateSnapshot === true ? 'true' : 'false',\n        continue_on_pause: 'false',\n      },\n      headers: { Accept: 'text/event-stream' },\n      signal: opts.signal,\n      throwOnError: true,\n    })\n    if (res.body === null) throw new Error('reconnect stream body missing')\n    return normalizeDifyStream(parseSSE(res.body, opts.signal))\n  }\n}\n","sourceCodeStart":81,"sourceCodeEnd":103,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/cli/src/api/app-run.ts#L81-L103","documentation":"Raised by DatasetsHitTestingBase.get_and_validate_dataset, a shared helper invoked by the hit-testing endpoints. Identical semantics to the inline dataset lookups: DatasetService.get_dataset(dataset_id, session) returned None. The helper additionally resolves the account via resolve_account_fallback and then runs check_dataset_permission, but the NotFound is purely an existence check on the dataset row.","triggerScenarios":"Calling any hit-testing endpoint (e.g. POST /datasets/{dataset_id}/hit-testing) with a dataset_id that has no row in the datasets table. The helper is invoked after request model validation, so malformed UUIDs are caught earlier by the route converter.","commonSituations":"Dataset was deleted between the user opening the hit-testing panel and submitting the query; wrong dataset_id passed from an orchestration script; tenant isolation returning None because the dataset belongs to a different tenant when the lookup is scoped elsewhere.","solutions":["Confirm the dataset exists and is accessible to the current tenant via GET /datasets/{dataset_id} before calling hit-testing.","Handle 404 responses in the client by refreshing the dataset list and clearing stale references.","If scripting, assert the dataset_id is present in the listed datasets before issuing the hit-testing call."],"exampleFix":"# before\ndataset = DatasetsHitTestingBase.get_and_validate_dataset(session, dataset_id, user)\n# after — guard at the caller with an explicit existence/permission pre-check\nfrom services.dataset_service import DatasetService\nif DatasetService.get_dataset(dataset_id, session) is None:\n    return None  # caller surfaces a friendly \"dataset missing\" message\ndataset = DatasetsHitTestingBase.get_and_validate_dataset(session, dataset_id, user)","handlingStrategy":"validation","validationCode":"async function ensureDatasetForHitTesting(client, datasetId, tenantId) {\n  const r = await client.get(`/console/api/datasets/${datasetId}`);\n  if (r.status === 404) throw new Error('Dataset not available for hit testing');\n  if (r.status === 403) throw new Error('No permission to test this dataset');\n  return true;\n}","typeGuard":"function isKnownDatasetId(id: string, knownIds: Set<string>): boolean {\n  return knownIds.has(id);\n}","tryCatchPattern":"try {\n  await hitTesting(client, datasetId, query);\n} catch (e) {\n  if (e.response?.status === 404) { await refreshDatasetList(); return; }\n  if (e.response?.status === 403) { notifyNoPermission(); return; }\n  throw e;\n}","preventionTips":["Pre-check dataset existence with GET /datasets/{id} before calling hit-testing endpoints.","Track dataset_ids obtained from the list response and discard ones that disappear on reload.","Do not retry the same dataset_id after a 404 without refreshing."],"tags":["dataset","hit-testing","not-found","rest-api","console","shared-helper"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}