Authentik: reads checked live; inspector says what a non-JSON answer is

Inspect on a real Authentik showed the version, outposts, certificates, tokens and events answer as the reader expects; /admin/workers/ answered with something that is not JSON, so the worker count stays unknown (no alert on a guess). The inspector now records the content type and what a non-JSON answer looks like (a web page, markup, metrics text, plain text; never its words) and shows it with the HTTP status on the page and in the copied report. Tests and docs updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-17 19:32:32 +01:00
1 parent 730d7fb36e
commit 76d6bfa85e
7 files changed
+44 -6

No files matched your search

+1 -1
View File
@@ -1855,7 +1855,7 @@ export interface IntegrationInspection {
ok: boolean;
error: string | null;
ms: number;
calls: { method: string; path: string; status: number; ms: number; bytes: number; shape: string | null; error?: string }[];
calls: { method: string; path: string; status: number; ms: number; bytes: number; shape: string | null; contentType?: string; looks?: string; error?: string }[];
resultShape: string | null;
empty: { path: string; what: "null" | "text" | "list" | "every-item" }[];
}
+8 -1
View File
@@ -15,6 +15,12 @@ const EMPTY_WORDS: Record<IntegrationInspection["empty"][number]["what"], string
"every-item": "is empty in every item of the list",
};
/** What to say of an answer that was not JSON: its status, its content type and what the text looks like — never its words. */
function notJson(c: IntegrationInspection["calls"][number]): string {
const bits = [`HTTP ${c.status}`, c.contentType, c.bytes === 0 ? "empty" : c.looks ? `looks like ${c.looks}` : null].filter(Boolean);
return `The answer was not JSON (${bits.join(", ")}).`;
}
/** The report as plain text, to be pasted into a message: only shapes, no values. */
function reportText(i: IntegrationSummary, r: IntegrationInspection): string {
const lines = [`Inspection of ${TYPE_LABELS[i.type]} "${i.name}" — ${r.ok ? "the read worked" : `the read failed: ${r.error}`} (${r.ms} ms)`, ""];
@@ -22,6 +28,7 @@ function reportText(i: IntegrationSummary, r: IntegrationInspection): string {
for (const c of r.calls) {
lines.push(` ${c.method} ${c.path} → ${c.status === 0 ? `no answer (${c.error ?? "?"})` : c.status} · ${c.ms} ms · ${c.bytes} bytes`);
if (c.shape) lines.push(` ${c.shape}`);
else if (c.status !== 0) lines.push(` ${notJson(c)}`);
}
lines.push("", "What the reader made of it:", ` ${r.resultShape ?? "(nothing)"}`, "", "Empty in it:");
if (r.empty.length === 0) lines.push(" nothing");
@@ -98,7 +105,7 @@ export default function IntegrationInspector({ integration, onClose }: { integra
</div>
{c.error && <div className="text-red small">{c.error}</div>}
{c.shape && <pre className="small text-secondary mb-0 mt-1" style={{ whiteSpace: "pre-wrap", wordBreak: "break-word" }}>{c.shape}</pre>}
{!c.shape && c.status !== 0 && <div className="text-secondary small">The answer was not JSON{c.bytes === 0 ? " (it was empty)" : ""}.</div>}
{!c.shape && c.status !== 0 && <div className="text-secondary small">{notJson(c)}</div>}
</div>
))}