DC-130 rev2: fail-fast bridge bindings (host), /status gateway-error mapping (401/403/unreachable -> 502, probe-failure stays ok:false) + 3 new tests (13 total)
This commit is contained in:
@@ -117,9 +117,27 @@ module.exports = function ({ asyncHandler, log, auditLogger, fetchT }) {
|
||||
if (!SERVICE_RE.test(service)) {
|
||||
return errorResponse(res, 400, 'invalid service name');
|
||||
}
|
||||
const { status, body } = await bridge('GET', `/api/status?service=${encodeURIComponent(service)}`);
|
||||
// shipdeck status exits non-zero when checks fail — surface that as ok:false
|
||||
// with the probe output so the UI can render the failing checks.
|
||||
let status, body;
|
||||
try {
|
||||
({ status, body } = await bridge('GET', `/api/status?service=${encodeURIComponent(service)}`));
|
||||
} catch (e) {
|
||||
log.error('deploys', 'status probe: bridge unreachable', { service, error: e.message });
|
||||
return errorResponse(res, 502, 'shipdeck bridge unreachable: ' + e.message);
|
||||
}
|
||||
if (status === 401 || status === 403) {
|
||||
// bridge auth/protocol failure = infrastructure problem, NOT a probe result
|
||||
log.error('deploys', 'status probe: bridge auth failed', { service, status });
|
||||
return errorResponse(res, 502, 'shipdeck bridge rejected the request (auth/config error)');
|
||||
}
|
||||
if (status >= 500 && body && body.ok === false && body.output) {
|
||||
// shipdeck status exits non-zero when checks fail — that's an EXPECTED
|
||||
// probe result (failing checks), surface as ok:false with the output.
|
||||
return ok(res, { ok: false, output: body.output || '' });
|
||||
}
|
||||
if (status !== 200) {
|
||||
// malformed upstream route or other unexpected bridge failure
|
||||
return errorResponse(res, 502, body && body.error ? body.error : 'unexpected bridge response');
|
||||
}
|
||||
return ok(res, { ok: body.ok === true, output: body.output || '' });
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user