{"record":{"id":"b4c66922a202a2d5","repo":"screenpipe/screenpipe","slug":"post-artifacts-register-returned-res-status","errorCode":null,"errorMessage":"POST /artifacts/register returned ${res.status}","messagePattern":"POST /artifacts/register returned (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/screenpipe-core/assets/acp/screenpipe-tools.mjs","lineNumber":681,"sourceCode":"      mkdirSync(tmpDir, { recursive: true });\n      const tmpPath = join(tmpDir, filename);\n      if (encoding === \"base64\") {\n        writeFileSync(tmpPath, Buffer.from(content, \"base64\"));\n      } else {\n        writeFileSync(tmpPath, content, \"utf-8\");\n      }\n      const res = await fetch(`${apiBase()}/artifacts/register`, {\n        method: \"POST\",\n        headers: authHeaders(),\n        body: JSON.stringify({\n          source: sessionId,\n          source_type: \"chat\",\n          title: args?.title || filename.replace(extname(filename), \"\").replace(/[-_]/g, \" \"),\n          kind,\n          file_path: tmpPath,\n        }),\n      });\n      if (!res.ok) throw new Error(`POST /artifacts/register returned ${res.status}`);\n      return JSON.stringify({ status: \"saved\", filename, kind });\n    },\n  },\n  {\n    name: \"sp_web_search\",\n    description:\n      \"Search the public internet via Google Search. Use ONLY for public, external information the user explicitly asks about (current events, news, public people or companies, public product docs). Do NOT use it for the user's own screenpipe data. When unsure, do not search. Returns results with sources.\",\n    inputSchema: {\n      type: \"object\",\n      properties: {\n        query: { type: \"string\", description: \"The search query\" },\n      },\n      required: [\"query\"],\n      additionalProperties: false,\n    },\n    async run(args) {\n      const query = String(args?.query ?? \"\").trim();\n      if (!query) throw new Error(\"query is required\");","sourceCodeStart":663,"sourceCodeEnd":699,"githubUrl":"https://github.com/screenpipe/screenpipe/blob/4ebf712990fee17eeaf904dacf749b6e96ac9bf3/crates/screenpipe-core/assets/acp/screenpipe-tools.mjs#L663-L699","documentation":"save_artifact writes the content to a session temp file, then POSTs it to the local engine at /artifacts/register. Any non-OK HTTP status from that endpoint is converted to this error carrying the status code. The temp file is already written, but registration (indexing/visibility in the Artifacts library) failed.","triggerScenarios":"Local screenpipe API down or restarting (ECONNREFUSED would surface as fetch rejection; other statuses here), 401 when auth token is stale, 404 when the engine version lacks /artifacts/register, 500 on engine-side write/index failure.","commonSituations":"Engine not yet started or updated while the agent session is running; port mismatch between apiBase() and the running server; backend bug rejecting the kind/file_path payload.","solutions":["Check the screenpipe engine is running and apiBase() points at the right host/port.","Read the status: 401/403 → re-authenticate the app; 404 → update the engine to a version with /artifacts/register; 5xx → check engine logs for the registration failure.","Retry the save_artifact call once the engine is healthy; the temp file is reused/upserted by session."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const res = await fetch(`${apiBase()}/health`); if (!res.ok) throw new Error(\"engine not ready; abort save_artifact\");","typeGuard":null,"tryCatchPattern":"try { await save_artifact(args) } catch (e) { if (/POST \\/artifacts\\/register returned (\\d+)/.test(e.message)) { const status = +RegExp.$1; if (status >= 500 || status === 429) retryWithBackoff(); else reportToUser(status); } else throw e }","preventionTips":["Confirm the engine is running before agent sessions","Pin engine versions that include /artifacts/register","Log response status + engine logs on failure"],"tags":["http","api","network"],"backgroundTag":"http-request-failed","analyzedSha":"4ebf712990fee17eeaf904dacf749b6e96ac9bf3","analyzedAt":"2026-09-01T23:33:43.065Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}