{"record":{"id":"adb111717a85e03a","repo":"mem0ai/mem0","slug":"context-failed-in-neptune-analytics","errorCode":null,"errorMessage":"${context} failed in Neptune Analytics","messagePattern":"(.+?) failed in Neptune Analytics","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/neptune_analytics.ts","lineNumber":1030,"sourceCode":"      return undefined;\n    }\n\n    const numericScore = Number(score);\n    if (!Number.isFinite(numericScore)) {\n      return undefined;\n    }\n\n    // Neptune returns squared Euclidean distance, while Memory search expects higher-is-better scores.\n    return 1 / (1 + Math.max(0, numericScore));\n  }\n\n  private assertSuccessfulResults(\n    results: NeptuneQueryRecord[],\n    context: string,\n  ): void {\n    for (const record of results) {\n      if (\"success\" in record && record.success !== true) {\n        throw new Error(`${context} failed in Neptune Analytics`);\n      }\n    }\n  }\n\n  /**\n   * Load the optional AWS SDK on first use.\n   *\n   * This MUST be a dynamic `import()`, never `require()`: tsup/esbuild rewrite\n   * `require()` in the published ESM bundle (`dist/oss/index.mjs`) into a\n   * `__require` shim that throws `Dynamic require of \"...\" is not supported`,\n   * so every ESM consumer would hit a dead provider even with the SDK installed.\n   */\n  private async getSDK(): Promise<NeptuneSDK> {\n    if (!this.sdkPromise) {\n      this.sdkPromise = import(\"@aws-sdk/client-neptune-graph\").then(\n        (sdk) => sdk as unknown as NeptuneSDK,\n        (err) => {\n          // Let a later call retry rather than caching the rejection forever.","sourceCodeStart":1012,"sourceCodeEnd":1048,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/neptune_analytics.ts#L1012-L1048","documentation":"Neptune Analytics batch queries return per-record success flags rather than failing the whole statement. After each batch operation the store scans the result records and throws if any record reports success !== true, converting a partial failure into a visible error instead of silently dropping rows.","triggerScenarios":"Batch insert/update/delete where at least one record fails server-side — e.g. a vertex write rejected due to schema, throttling, or an invalid ID — while the HTTP call itself returned 200.","commonSituations":"Large bulk imports that partially succeed; concurrent writers causing throttling; malformed individual records (too-long IDs, type mismatches) inside an otherwise valid batch.","solutions":["Log the failing batch's inputs and retry only the failed records (the batch is partially applied).","Reduce batch size to isolate the offending record and inspect it for malformed IDs or values.","Check AWS CloudWatch logs for the Neptune Analytics graph to see the per-record failure reason."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await store.insert(vectors, ids, payloads);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('failed in Neptune Analytics')) {\n    // batch is partially applied: reconcile ids then retry the missing ones\n    const existing = new Set(await listExistingIds(ids));\n    const retryIds = ids.filter((id) => !existing.has(id));\n    await retryInsert(retryIds);\n  } else throw e;\n}","preventionTips":["Keep batches small so partial failures are cheap to reconcile","Make writes idempotent (stable record IDs)","Check record-level success flags in AWS CloudWatch during bulk loads"],"tags":["neptune-analytics","batch","partial-failure","aws"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}