{"record":{"id":"6ed45224d8e19bde","repo":"hcengineering/platform","slug":"attachment-is-missing-parentid-parentclass-or-spa","errorCode":null,"errorMessage":"Attachment is missing parentId, parentClass or spaceId","messagePattern":"Attachment is missing parentId, parentClass or spaceId","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/importer/src/importer/importer.ts","lineNumber":330,"sourceCode":"        await this.importTeamspace(space as ImportTeamspace)\n      } else if (space.class === tracker.class.Project) {\n        await this.importProject(space as ImportProject)\n      } else if (space.class === documents.class.OrgSpace) {\n        await this.importOrgSpace(space as ImportOrgSpace)\n      }\n    }\n  }\n\n  private async importAttachments (): Promise<void> {\n    if (this.workspaceData.attachments === undefined) return\n\n    for (const attachment of this.workspaceData.attachments) {\n      if (\n        attachment.parentId === undefined ||\n        attachment.parentClass === undefined ||\n        attachment.spaceId === undefined\n      ) {\n        throw new Error('Attachment is missing parentId, parentClass or spaceId')\n      }\n      await this.importAttachment(attachment.parentId, attachment.parentClass, attachment, attachment.spaceId)\n    }\n  }\n\n  async createProjectTypeWithTaskTypes (projectType: ImportProjectType): Promise<Ref<ProjectType>> {\n    const taskTypes: TaskTypeWithFactory[] = []\n    if (projectType.taskTypes !== undefined) {\n      for (const taskType of projectType.taskTypes) {\n        const taskTypeId = generateId<TaskType>()\n        const statuses = taskType.statuses.map((status) => {\n          return {\n            name: status.name,\n            ofAttribute: tracker.attribute.IssueStatus,\n            category: task.statusCategory.Active\n          }\n        })\n        taskTypes.push({","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/importer/src/importer/importer.ts#L312-L348","documentation":"During import, the importer validates that every attachment record carries the three fields required to attach it in the target workspace: parentId (the doc it attaches to), parentClass (the class of that doc), and spaceId (the owning space). If any is undefined, the import is aborted with this error before any upload is attempted, because an attachment without these cannot be placed via client.addCollection.","triggerScenarios":"workspaceData.attachments contains an entry built by a source-adapter (e.g. GitHub/Jira export) that failed to resolve the issue/doc or space the attachment belongs to, leaving parentId, parentClass or spaceId undefined; or a hand-written ImportAttachment object omitted one of the fields.","commonSituations":"Importing an export where an attachment referenced a deleted/unknown issue so the converter could not backfill its parent; migrating between tracker versions where the attachment shape gained required fields; manually editing exported JSON and dropping a field.","solutions":["Inspect the failing attachment record (log workspaceData.attachments before the loop) and identify which of the three fields is undefined","Fix the source adapter/export so it resolves parentId, parentClass and spaceId for every attachment (skip or drop attachments whose parent could not be resolved)","If manually editing import data, set parentClass to the parent doc's class (e.g. 'tracker:class:Issue') and spaceId to the target project/space Ref","Upgrade to a matching exporter/importer version pair so attachment shapes agree"],"exampleFix":"// before\n{ name: 'screenshot.png', data: fileBlob } // missing parentId/spaceId\n// after\n{ name: 'screenshot.png', data: fileBlob, parentId: issueId, parentClass: 'tracker:class:Issue', spaceId: projectId }","handlingStrategy":"validation","validationCode":"function validateAttachment(a) {\n  const missing = ['parentId', 'parentClass', 'spaceId'].filter(k => a[k] === undefined)\n  if (missing.length > 0) throw new Error(`Attachment ${a.name ?? a._id} missing: ` + missing.join(', '))\n}\nworkspaceData.attachments.forEach(validateAttachment)","typeGuard":"function hasAttachmentRefs(a): a is typeof a & { parentId: NonNullable<typeof a.parentId>, parentClass: NonNullable<typeof a.parentClass>, spaceId: NonNullable<typeof a.spaceId> } {\n  return a.parentId !== undefined && a.parentClass !== undefined && a.spaceId !== undefined\n}","tryCatchPattern":"try {\n  await importer.importAttachments()\n} catch (err) {\n  if (err.message.includes('Attachment is missing')) {\n    console.error('Malformed import data:', err.message)\n  } else throw err\n}","preventionTips":["Validate the full export/ImportWorkspace shape before starting the import","Ensure the source adapter skips (with a warning) attachments whose parent doc could not be resolved","Log the index and name of each attachment processed so failures are locatable","Keep exporter and importer versions in sync"],"tags":["importer","attachments","missing-required-field"],"backgroundTag":"missing-required-field","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}