Clarify Gitea verification failure diagnostics
Verify and publish checkpoint container / container (push) Canceled after 0s
Verify and publish checkpoint container / container (push) Canceled after 0s
This commit is contained in:
1 parent
c414a03a19
commit
0681529e8e
6 files changed
+126
-25
No files matched your search
+24
-13
@@ -13,6 +13,7 @@ import { verifyParticipantAi } from './admin-seat-ai-verification.mjs';
|
||||
import { verifyRoomArchive } from './admin-archive-verification.mjs';
|
||||
import { verifyRoomClosure } from './admin-closure-verification.mjs';
|
||||
import { verifyRoomRemoval } from './admin-removal-verification.mjs';
|
||||
import { requestIdentity, requestFailure, failureLocation } from './admin-verification-diagnostics.mjs';
|
||||
|
||||
const options = {};
|
||||
for (let n = 2; n < process.argv.length; n += 2) {
|
||||
@@ -33,18 +34,28 @@ const key = (await readFile(options['--key-file'], 'utf8')).trim();
|
||||
const base = url.origin;
|
||||
const report = { origin: base, startedAt: new Date().toISOString(), passed: false, checks: [], room: null };
|
||||
let session1, session2, adminId;
|
||||
const requestFailures = new WeakMap();
|
||||
async function request(path, body, cookie, origin = base, expectedAdminId = adminId) {
|
||||
const response = await fetch(base + path, {
|
||||
method: body === undefined ? 'GET' : 'POST',
|
||||
headers: { ...(body === undefined ? {} : { 'content-type': 'application/json', origin }), ...(cookie ? { cookie } : {}),
|
||||
...(expectedAdminId && (path === '/api/admin/audit' || path.startsWith('/api/admin/audit?') || path === '/api/admin/rooms' && body !== undefined || /^\/api\/admin\/rooms\/[^/]+\/(control|lobby|removal|closure|archive|seat-ai|discussion)$/.test(path)) ? { 'X-Dune-Admin-Id': expectedAdminId } : {}) },
|
||||
...(body === undefined ? {} : { body: JSON.stringify(body) }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
report.lastRequest = { path, status: response.status };
|
||||
const raw = await response.text();
|
||||
let data;
|
||||
try { data = JSON.parse(raw); } catch { data = null; }
|
||||
return { status: response.status, data, cookie: response.headers.get('set-cookie')?.split(';')[0], rawCookie: response.headers.get('set-cookie'), cache: response.headers.get('cache-control') };
|
||||
const identity = requestIdentity(body === undefined ? 'GET' : 'POST', path);
|
||||
report.inFlightRequest = identity;
|
||||
try {
|
||||
const response = await fetch(base + path, {
|
||||
method: body === undefined ? 'GET' : 'POST',
|
||||
headers: { ...(body === undefined ? {} : { 'content-type': 'application/json', origin }), ...(cookie ? { cookie } : {}),
|
||||
...(expectedAdminId && (path === '/api/admin/audit' || path.startsWith('/api/admin/audit?') || path === '/api/admin/rooms' && body !== undefined || /^\/api\/admin\/rooms\/[^/]+\/(control|lobby|removal|closure|archive|seat-ai|discussion)$/.test(path)) ? { 'X-Dune-Admin-Id': expectedAdminId } : {}) },
|
||||
...(body === undefined ? {} : { body: JSON.stringify(body) }), signal: AbortSignal.timeout(15000),
|
||||
});
|
||||
report.lastRequest = { ...identity, status: response.status };
|
||||
const raw = await response.text();
|
||||
let data;
|
||||
try { data = JSON.parse(raw); } catch { data = null; }
|
||||
return { status: response.status, data, cookie: response.headers.get('set-cookie')?.split(';')[0], rawCookie: response.headers.get('set-cookie'), cache: response.headers.get('cache-control') };
|
||||
} catch (error) {
|
||||
if (error && typeof error === 'object') requestFailures.set(error, requestFailure(identity, error));
|
||||
throw error;
|
||||
} finally {
|
||||
delete report.inFlightRequest;
|
||||
}
|
||||
}
|
||||
try {
|
||||
const denied = await request('/api/admin/rooms');
|
||||
@@ -115,8 +126,8 @@ try {
|
||||
} catch (error) {
|
||||
// Do not serialize assertion payloads: failed authentication responses might contain credentials.
|
||||
report.failure = 'Administrator HTTP verification failed. Investigate the last completed check.';
|
||||
report.failureRequest ??= report.lastRequest;
|
||||
report.failureLocation = error instanceof Error ? error.stack?.split('\n').find(line => line.trim().startsWith('at ') && line.includes('verify-admin.mjs'))?.trim() : undefined;
|
||||
report.failureRequest = (error && typeof error === 'object' ? requestFailures.get(error) : undefined) ?? report.failureRequest ?? report.lastRequest;
|
||||
report.failureLocation = failureLocation(error);
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
for (const cookie of [session1, session2].filter(Boolean)) {
|
||||
|
||||
Reference in new issue
Block a user