fix: send type in api response, trim whitespace from stacktrace, escape stack trace

This commit is contained in:
Julian Lam
2026-04-15 10:52:06 -04:00
parent e22d2e4169
commit 1b663d3e92
2 changed files with 5 additions and 8 deletions

View File

@@ -1,5 +1,7 @@
'use strict';
const validator = require('validator');
const db = require('../../database');
const activitypub = require('../../activitypub');
const analytics = require('../../analytics');
@@ -93,17 +95,18 @@ federationController.errors = async function (req, res) {
if (!errorObj[idx]) {
return null;
}
let { body, stack } = errorObj[idx];
let { type, body, stack } = errorObj[idx];
let hostname = 'Invalid hostname';
const timestampISO = new Date(timestamp).toISOString();
try {
body = JSON.stringify(JSON.parse(body), null, 4);
stack = validator.escape(stack.replace(/\s+$/gm, ''));
({ hostname } = new URL(id));
} catch (e) {
// noop
}
return { id, body, stack, hostname, timestamp, timestampISO };
return { id, type, body, stack, hostname, timestamp, timestampISO };
}).filter(Boolean);
res.render('admin/federation/errors', {

View File

@@ -20,12 +20,6 @@
{{{ if ./stack }}}
<pre class="m-2 border p-2"><code>{./stack}</code></pre>
{{{ end }}}
{{{ if ./body }}}
<!-- <pre class="m-2 border p-2"><code>{./body}</code></pre> -->
{{{ else }}}
<em>[[admin/settings/activitypub:errors.payload-gone]]</em>
{{{ end }}}
</details>
{{{ end }}}
</div>