{"record":{"id":"66fd66dc56f11101","repo":"mem0ai/mem0","slug":"failed-to-update-vector-error-instanceof-error","errorCode":null,"errorMessage":"Failed to update vector: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Failed to update vector: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/vectorize.ts","lineNumber":185,"sourceCode":"        {\n          method: \"POST\",\n          headers: {\n            \"Content-Type\": \"application/x-ndjson\",\n            Authorization: `Bearer ${this.client?.apiToken}`,\n          },\n          body: JSON.stringify(data) + \"\\n\", // ndjson format\n        },\n      );\n\n      if (!response.ok) {\n        const errorText = await response.text();\n        throw new Error(\n          `Failed to update vector: ${response.status} ${errorText}`,\n        );\n      }\n    } catch (error) {\n      console.error(\"Error updating vector:\", error);\n      throw new Error(\n        `Failed to update vector: ${error instanceof Error ? error.message : String(error)}`,\n      );\n    }\n  }\n\n  async delete(vectorId: string): Promise<void> {\n    await this.initialize();\n    try {\n      await this.client?.vectorize.indexes.deleteByIds(this.indexName, {\n        account_id: this.accountId,\n        ids: [vectorId],\n      });\n    } catch (error) {\n      console.error(\"Error deleting vector:\", error);\n      throw new Error(\n        `Failed to delete vector: ${error instanceof Error ? error.message : String(error)}`,\n      );\n    }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/vectorize.ts#L167-L203","documentation":"Generic catch wrapper around the Vectorize update path: any exception (including the non-ok HTTP throw from the sibling branch, network failure, or serialization error) is logged and rethrown as 'Failed to update vector: <message>'. The inner message identifies the true failure.","triggerScenarios":"Any exception during memory.update(): network drop mid-request, expired token, inner 4xx from the upsert endpoint, TypeError building the NDJSON body.","commonSituations":"Serverless timeouts cutting the request; rotated API tokens; transient Cloudflare 5xx on upsert.","solutions":["Unwrap and act on the inner message (auth/dimension/index-name fixes as in the sibling error).","Retry with backoff for transient causes; updates upsert by id so a retry is safe.","Refresh the API token if credentials are the cause."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await memory.update(id, data); } catch (e) { const m = e instanceof Error ? e.message : ''; if (m.startsWith('Failed to update vector:') && isTransient(m)) await retryWithBackoff(() => memory.update(id, data), 3); else throw e; }","preventionTips":["Classify the inner message before retrying","Log inner cause, not just the wrapper","Use stable memory ids so retried upserts are idempotent"],"tags":["cloudflare","vectorize","update","error-wrapping"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}