{"record":{"id":"6ba0c7f2337e4ab2","repo":"medusajs/medusa","slug":"indexmodule-error-unable-to-handle-attach-event-f-6ba0c7","errorCode":null,"errorMessage":"IndexModule error, unable to handle attach event for ${entity}. The child entity name could not be found using the linkable keys from the module ${childServiceName}.","messagePattern":"IndexModule error, unable to handle attach event for (.+?)\\. The child entity name could not be found using the linkable keys from the module (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/modules/index/src/services/postgres-provider.ts","lineNumber":629,"sourceCode":"\n    /**\n     * Retrieve the property that represent the foreign key related to the child entity of the link entity.\n     * Then from the service name of the child entity, retrieve the entity name using the linkable keys.\n     */\n\n    const childPropertyId =\n      schemaEntityObjectRepresentation.moduleConfig.relationships![1].foreignKey\n    const childServiceName =\n      schemaEntityObjectRepresentation.moduleConfig.relationships![1]\n        .serviceName\n    const childEntityName = (\n      this.schemaObjectRepresentation_._serviceNameModuleConfigMap[\n        childServiceName\n      ] as IndexTypes.EntityNameModuleConfigMap[0]\n    ).linkableKeys?.[childPropertyId]\n\n    if (!childEntityName) {\n      throw new Error(\n        `IndexModule error, unable to handle attach event for ${entity}. The child entity name could not be found using the linkable keys from the module ${childServiceName}.`\n      )\n    }\n\n    /**\n     * Clean the link entity data to only keep the properties that are defined in the schema\n     */\n\n    const cleanedData = data_.map((entityData) => {\n      return entityProperties.reduce((acc, property) => {\n        acc[property] = entityData[property]\n        return acc\n      }, {}) as TData\n    })\n\n    let relationsToUpsert: any[] = []\n    const entitiesToUpsert = cleanedData.map((entityData) => {\n      relationsToUpsert.push(","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/index/src/services/postgres-provider.ts#L611-L647","documentation":"Mirror of error 618 for the child side: when handling an attach event for a link entity, the child's FK cannot be mapped to an entity name via the child module's linkableKeys, so event processing fails.","triggerScenarios":"Link event where the child property key is absent from the child service's linkableKeys map — custom links not surfaced to the index schema, or renamed child relation properties.","commonSituations":"Same as parent variant: custom links, schema customization, or version drift between the link definition and the index configuration.","solutions":["Register the child relation in the index schema so its linkableKeys cover the FK","Fix/align the module configuration exposing linkableKeys","Re-run a full index sync after correcting configuration"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const linkableKeys = schema._serviceNameModuleConfigMap[childServiceName]?.linkableKeys ?? {}\nif (!(childPropertyId in linkableKeys)) { /* add child relation to index schema */ }","typeGuard":null,"tryCatchPattern":"try { await indexService.onAttach(...) } catch (e) { if (/child entity name could not be found/.test(e.message)) { logger.warn('Child link key unmapped') } }","preventionTips":["Register child-side linkable keys in module config","Align module and index package versions after upgrades"],"tags":["index","links","attach-event","configuration"],"backgroundTag":"schema-configuration-mismatch","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}