{"version":15,"agent":"pinch","message":"--attach says plainly when the Issues server doesn't take attachments yet\n\nA server from before attachments has no upload route. It answered 400 'the body is JSON', or 404, and the client printed that as it came, which told nobody what had happened. Now the client says the server doesn't take attachments yet, that the file wasn't sent and nothing was written, and to leave --attach off or link the image instead. A server that has the route but nowhere to keep files (501) gets the same message. A test checks the message and that no issue is opened.","time":1791520723403,"timeIso":"2026-10-09T04:38:43.403Z","changes":3,"change":141,"files":["client/src/api.ts","client/test/attach.test.ts"],"draft":null,"diff":[{"path":"client/src/api.ts","added":7,"removed":0,"diff":"--- a/client/src/api.ts\n+++ b/client/src/api.ts\n@@ -424,6 +424,13 @@\n \t\t\t);\n \t\t}\n \t\tconst text = await res.text();\n+\t\t// A server from before attachments has no upload route: it answers 404, or 400 because the body isn't JSON;\n+\t\t// one with the route but nowhere to keep files answers 501. Say so plainly, and that nothing was sent.\n+\t\tif (res.status === 404 || res.status === 501 || (res.status === 400 && /the body is JSON/.test(text)))\n+\t\t\tthrow new ApiError(\n+\t\t\t\t`${this.issuesServer} doesn't take attachments yet, so ${name} wasn't sent and nothing was written. Leave --attach off, or link the image instead.`,\n+\t\t\t\tres.status,\n+\t\t\t);\n \t\tif (!res.ok) throw new ApiError(`uploading ${name} answered ${res.status}: ${errorSentence(text)}`, res.status);\n \t\treturn JSON.parse(text) as Attachment;\n \t}"},{"path":"client/test/attach.test.ts","added":20,"removed":0,"diff":"--- a/client/test/attach.test.ts\n+++ b/client/test/attach.test.ts\n@@ -31,6 +31,9 @@\n \t\t\tconst body = Buffer.concat(parts);\n \t\t\tseen.push({ method: req.method!, url: req.url!, headers: req.headers, body });\n \t\t\tconst json = (o: unknown) => res.writeHead(200, { \"content-type\": \"application/json\" }).end(JSON.stringify(o));\n+\t\t\t// A server from before attachments: it reads every POST body as JSON.\n+\t\t\tif (req.url!.includes(\"/p/old\") && req.url!.endsWith(\"/attachments\"))\n+\t\t\t\treturn res.writeHead(400, { \"content-type\": \"application/json\" }).end('{\"error\":\"the body is JSON\"}');\n \t\t\tif (req.url!.endsWith(\"/attachments\"))\n \t\t\t\treturn json({\n \t\t\t\t\tid: `a${String(seen.length).padStart(12, \"0\")}`,\n@@ -113,6 +116,23 @@\n \t\tassert.match(alone.out, /--attach goes with avcs issue new or --comment/);\n \t});\n \n+\tit(\"says plainly when the server doesn't take attachments yet, and writes nothing\", async () => {\n+\t\tconst dir = mkdtempSync(join(tmpdir(), \"abso-attach-\"));\n+\t\tdirs.push(dir);\n+\t\tconst init = await avcs(dir, [\"init\", \"--server\", fake.url, \"--project\", \"old\", \"--agent\", \"ann\"]);\n+\t\tassert.equal(init.exit, 0, init.out);\n+\t\twriteFileSync(join(dir, \"shot.png\"), Buffer.from([0x89, 0x50, 0x4e, 0x47, 1]));\n+\t\tconst from = seen.length;\n+\t\tconst r = await avcs(dir, [\"issue\", \"new\", \"T\", \"--attach\", \"shot.png\"]);\n+\t\tassert.equal(r.exit, 1);\n+\t\tassert.match(r.out, /doesn't take attachments yet, so shot.png wasn't sent and nothing was written/);\n+\t\tassert.deepEqual(\n+\t\t\tseen.slice(from).map((c) => c.url.replace(/^\\/p\\/[^/]+/, \"\")),\n+\t\t\t[\"/a/ann/attachments\"],\n+\t\t\t\"no issue was opened\",\n+\t\t);\n+\t});\n+\n \tit(\"sends nothing when a file is missing\", async () => {\n \t\tconst dir = await folder();\n \t\tconst from = seen.length;"}],"ci":null}