Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 49 --json
JSON
/christopher/abso-core/versions/49?format=json

Errors: say an HTML error page by its title and Ray ID

of shared·pinch··Not checked

When the server fails before it can answer, its host sends an HTML error page instead. The client printed the page's first 300 characters, which are all doctype and IE comments, so nobody could tell what had failed: "GET /a/me/status answered 500: <!DOCTYPE html> <!--[if lt IE 7]> ...".

Now an HTML answer reads: answered 500: an HTML error page titled "Worker threw exception | ... | Cloudflare" (Ray ID ...), not the server's own answer: the server failed before it could say why. The title and Ray ID are what an operator needs to find the failure. JSON answers and plain text are said as before. Tested in error-sentence.test.ts.

Version 48 · Files at version 49

2 files, 44 lines added, 1 removed.

--- a/client/src/api-error.ts
+++ b/client/src/api-error.ts
@@ -36,7 +36,10 @@
3636 );
3737}
3838
39−/** The server's `{error: "sentence"}` answer, or the start of whatever it sent. */
39+/**
40+ * The server's `{error: "sentence"}` answer, or the start of whatever it sent. An HTML page (the host's error
41+ * page, when the server itself failed) is said by its title and Ray ID, which its first lines never reach.
42+ */
4043export function errorSentence(body: string): string {
4144 try {
4245 const parsed = JSON.parse(body) as { error?: unknown; reason?: unknown };
@@ -45,5 +48,15 @@
4548 } catch {
4649 // Not JSON.
4750 }
51+ if (/^\s*<(!doctype html|html)/i.test(body)) {
52+ const plain = (s: string) =>
53+ s
54+ .replace(/<[^>]*>/g, " ")
55+ .replace(/\s+/g, " ")
56+ .trim();
57+ const title = plain(/<title>([\s\S]*?)<\/title>/i.exec(body)?.[1] ?? "");
58+ const ray = /Ray ID:\s*(?:<[^>]*>\s*)*([0-9a-f]+)/i.exec(body)?.[1];
59+ return `an HTML error page${title !== "" ? ` titled ${JSON.stringify(title)}` : ""}${ray ? ` (Ray ID ${ray})` : ""}, not the server's own answer: the server failed before it could say why`;
60+ }
4861 return body.slice(0, 300);
4962}
--- /dev/null
+++ b/client/test/error-sentence.test.ts
@@ -0,0 +1,30 @@
1+// errorSentence: what an error answer says, from JSON or from the host's HTML error page.
2+
3+import assert from "node:assert/strict";
4+import { test } from "node:test";
5+import { errorSentence } from "../src/api-error.ts";
6+
7+test("a JSON answer gives its error, else its reason", () => {
8+ assert.equal(errorSentence('{"error":"no such draft"}'), "no such draft");
9+ assert.equal(errorSentence('{"reason":"paused"}'), "paused");
10+ assert.equal(errorSentence("plain words"), "plain words");
11+});
13+test("an HTML error page is said by its title and Ray ID, not its first lines", () => {
14+ const page = `<!DOCTYPE html>
15+<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
16+<head>
17+<title>Worker threw exception | example.workers.dev | Cloudflare</title>
18+</head>
19+<body>${"<div></div>\n".repeat(50)}
20+<span>Cloudflare Ray ID: <strong class="font-semibold">8c1f2e3d4a5b6c7d</strong></span>
21+</body></html>`;
22+ assert.equal(
23+ errorSentence(page),
24+ 'an HTML error page titled "Worker threw exception | example.workers.dev | Cloudflare" (Ray ID 8c1f2e3d4a5b6c7d), not the server\'s own answer: the server failed before it could say why',
25+ );
26+ assert.equal(
27+ errorSentence("<html><body>oops</body></html>"),
28+ "an HTML error page, not the server's own answer: the server failed before it could say why",
29+ );
30+});