--attach says plainly when the Issues server doesn't take attachments yet Version 15 of shared· pinch· Oct 9 (2026-10-09 04:38 UTC) · Not checked
A 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.
Version 14 · Files at version 15
2 files, 27 lines added, 0 removed.
--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -424,6 +424,13 @@
426 426 const text = await res.text(); 427 + // A server from before attachments has no upload route: it answers 404, or 400 because the body isn't JSON; 428 + // one with the route but nowhere to keep files answers 501. Say so plainly, and that nothing was sent. 429 + if (res.status === 404 || res.status === 501 || (res.status === 400 && /the body is JSON/.test(text))) 431 + `${this.issuesServer} doesn't take attachments yet, so ${name} wasn't sent and nothing was written. Leave --attach off, or link the image instead.`, 427 434 if (!res.ok) throw new ApiError(`uploading ${name} answered ${res.status}: ${errorSentence(text)}`, res.status); 428 435 return JSON.parse(text) as Attachment; --- a/client/test/attach.test.ts
+++ b/client/test/attach.test.ts
@@ -31,6 +31,9 @@
31 31 const body = Buffer.concat(parts); 32 32 seen.push({ method: req.method!, url: req.url!, headers: req.headers, body }); 33 33 const json = (o: unknown) => res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify(o)); 34 + // A server from before attachments: it reads every POST body as JSON. 35 + if (req.url!.includes("/p/old") && req.url!.endsWith("/attachments")) 36 + return res.writeHead(400, { "content-type": "application/json" }).end('{"error":"the body is JSON"}'); 34 37 if (req.url!.endsWith("/attachments")) 36 39 id: `a${String(seen.length).padStart(12, "0")}`, @@ -113,6 +116,23 @@
113 116 assert.match(alone.out, /--attach goes with avcs issue new or --comment/); 119 + it("says plainly when the server doesn't take attachments yet, and writes nothing", async () => { 120 + const dir = mkdtempSync(join(tmpdir(), "abso-attach-")); 122 + const init = await avcs(dir, ["init", "--server", fake.url, "--project", "old", "--agent", "ann"]); 123 + assert.equal(init.exit, 0, init.out); 124 + writeFileSync(join(dir, "shot.png"), Buffer.from([0x89, 0x50, 0x4e, 0x47, 1])); 125 + const from = seen.length; 126 + const r = await avcs(dir, ["issue", "new", "T", "--attach", "shot.png"]); 127 + assert.equal(r.exit, 1); 128 + assert.match(r.out, /doesn't take attachments yet, so shot.png wasn't sent and nothing was written/); 130 + seen.slice(from).map((c) => c.url.replace(/^\/p\/[^/]+/, "")), 131 + ["/a/ann/attachments"], 132 + "no issue was opened", 116 136 it("sends nothing when a file is missing", async () => { 117 137 const dir = await folder(); 118 138 const from = seen.length;