{"record":{"id":"653a1a3fa4fd4092","repo":"mem0ai/mem0","slug":"vector-with-id-vectorid-not-found","errorCode":null,"errorMessage":"Vector with ID ${vectorId} not found","messagePattern":"Vector with ID (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/s3_vectors.ts","lineNumber":229,"sourceCode":"      }\n      throw error;\n    }\n  }\n\n  async update(\n    vectorId: string,\n    vector: number[],\n    payload: Record<string, any>,\n  ): Promise<void> {\n    await this.initialize();\n\n    let nextVector = vector;\n    let nextPayload = payload || {};\n\n    if (vector.length === 0 || !payload) {\n      const existing = await this.fetchStoredVector(vectorId);\n      if (!existing) {\n        throw new Error(`Vector with ID ${vectorId} not found`);\n      }\n      nextVector = vector.length > 0 ? vector : existing.vector;\n      nextPayload = payload || existing.payload;\n    }\n\n    this.assertVectorDimension(nextVector, \"Vector\");\n\n    const sdk = await this.getSdk();\n    const client = await this.getClient();\n    await client.send(\n      new sdk.PutVectorsCommand({\n        vectorBucketName: this.vectorBucketName,\n        indexName: this.collectionName,\n        vectors: [\n          {\n            key: vectorId,\n            data: this.toVectorData(nextVector),\n            metadata: nextPayload,","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/s3_vectors.ts#L211-L247","documentation":"updateVector in the S3 Vectors store supports partial updates: when the new vector is empty or the payload is missing, it fetches the stored vector to merge. If no stored vector with that ID exists, there is nothing to merge with and the update cannot proceed, so this error is thrown.","triggerScenarios":"Calling updateVector(id, [], newPayload) for an ID that was never added or was already deleted; passing an empty vector array with a new ID; stale IDs held in application state after the collection was recreated.","commonSituations":"Retry logic reusing IDs after the underlying collection was dropped; updating memories deleted by another process; partial-update code paths that omit the vector for records that do not exist yet.","solutions":["Check the memory exists before partial update (getVector / list) or simply add it instead","Pass the full vector when updating potentially-missing IDs so the call becomes an upsert-style put","Refresh cached IDs after collection recreation or bulk deletes"],"exampleFix":"// before\nawait s3vs.updateVector(id, [], { text: 'updated' }); // throws if absent\n\n// after\nconst existing = await s3vs.getVector(id);\nif (!existing) {\n  await s3vs.insert([/* embeddings */,], [id], [{ text: 'updated' }]);\n} else {\n  await s3vs.updateVector(id, [], { text: 'updated' });\n}","handlingStrategy":"try-catch","validationCode":"async function upsertVector(vs: any, id: string, vec: number[], payload: any) {\n  const existing = vec.length > 0 && payload ? null : await vs.getVector(id);\n  if (!existing && vec.length === 0) {\n    throw new Error(`Cannot partial-update missing vector ${id}; supply a full vector`);\n  }\n  await vs.updateVector(id, vec, payload);\n}","typeGuard":"const hasFullUpdateData = (vec: number[], payload?: any): boolean =>\n  vec.length > 0 && !!payload;","tryCatchPattern":"try {\n  await s3vs.updateVector(id, [], newPayload);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found')) {\n    await s3vs.insert([embedding], [id], [newPayload]); // create instead\n  } else throw e;\n}","preventionTips":["Check existence (or always send the full vector) before partial updates","Invalidate cached IDs after collection recreation or bulk deletes","Model update-vs-create explicitly in your memory service instead of relying on upsert semantics"],"tags":["s3-vectors","update","not-found","partial-update","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}