{"record":{"id":"90291cc6de0d246f","repo":"hcengineering/platform","slug":"no-documents-found-to-export","errorCode":null,"errorMessage":"No documents found to export","messagePattern":"No documents found to export","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"services/export/pod-export/src/server.ts","lineNumber":610,"sourceCode":"          const options: ExportOptions = {\n            sourceWorkspace: wsIds,\n            targetWorkspace: targetWsIds,\n            sourceQuery: query ?? {},\n            _class,\n            conflictStrategy: conflictStrategy ?? 'duplicate',\n            includeAttachments: includeAttachments ?? true,\n            relations,\n            fieldMappers,\n            skipDeletedObsolete: skipDeletedObsolete ?? true,\n            exportOnlyEffective: exportOnlyEffective ?? false,\n            includeChildren: includeChildren ?? false,\n            customHandlers: [createProductVersionHandler()]\n          }\n\n          const exportResult: ExportResult = await exporter.export(options)\n\n          if (exportResult.exportedCount === 0) {\n            res.status(400).send({ message: 'No documents found to export' })\n          }\n\n          if (exportResult.success) {\n            await sendExportCompletionNotification(\n              measureCtx,\n              targetTxOps,\n              targetWorkspace,\n              targetWsIds,\n              exportResult.exportedDocuments,\n              wsIds,\n              _class\n            )\n          }\n\n          res.status(200).send({ message: 'Export completed' })\n        } catch (err: any) {\n          measureCtx.error('Export failed:', err)\n          res.status(500).send({ message: 'Export failed', error: err.message ?? 'Unknown error' })","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/export/pod-export/src/server.ts#L592-L628","documentation":"The export job's completion check: after WorkspaceExporter.export runs, if exportResult.exportedCount === 0 the route responds 400 'No documents found to export'. This is not a crash — the export machinery worked but the query/class matched zero documents in the source workspace.","triggerScenarios":"POSTing an export request whose _class, query filter, or attributesOnly options select no documents: wrong class ref, query that matches nothing, or exporting from a workspace/region with no data of that class.","commonSituations":"Typo or wrong Ref.* constant in _class, an overly restrictive query (e.g. filtering on a modified-since date in the future), exporting an empty/sandbox workspace, or class names that differ across product versions.","solutions":["Verify the _class value matches a real class in the target workspace (check with the hierarchy client or dump).","Relax or print the query filter to confirm it matches documents; remove the query first to test class-level export.","Confirm the source workspace actually contains documents of that class (check via UI or API).","Check for class/Ref renames after product upgrades and update the client."],"exampleFix":"// before\nawait exportApi.export(token, { _class: 'contact:class:Contact ', query: { modifiedOn: { $gt: futureTs } } })\n// after\nawait exportApi.export(token, { _class: 'contact:class:Contact' })","handlingStrategy":"validation","validationCode":"// ensure the class exists and the query is not empty-limiting before export\nconst hierarchy = platformClient.getHierarchy()\nif (!hierarchy.isDerived(_class, core.class.Doc)) throw new Error(`unknown _class: ${_class}`)\nif (query && Object.keys(query).length > 0) {\n  const count = await countDocs(_class, query)\n  if (count === 0) console.warn('query matches no documents; export will 400')\n}","typeGuard":"function hasExportableDocs(result: { exportedCount: number }): boolean {\n  return result.exportedCount > 0\n}","tryCatchPattern":"const res = await exportApi.exportToWorkspace(token, payload)\nif (res.status === 400) {\n  const body = await res.json()\n  if (body.message === 'No documents found to export') {\n    console.warn('nothing matched — check _class and query')\n    return // not a hard failure\n  }\n}","preventionTips":["Validate _class values against Ref.* constants, not hand-typed strings","Dry-run the query against the source workspace before exporting","Sanity-check date-range filters (no future modifiedOn bounds)","Test exports against a workspace known to contain the class"],"tags":["export","http","empty-result","query"],"backgroundTag":"no-matching-documents","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}