fix: repair gitea github webhook sync egress

This commit is contained in:
Codex
2026-07-06 02:52:28 +00:00
parent d4c258ea59
commit a23691efd8
3 changed files with 38 additions and 8 deletions
@@ -56,7 +56,7 @@ createServer(async (req, res) => {
running.add(repo.key);
try {
const sync = syncRepository(repo);
log({ event: "github-to-gitea-sync", repo: repo.key, ok: sync.ok, sourceCommit: sync.sourceCommit, snapshotRef: sync.snapshotRef, elapsedMs: Date.now() - startedAt, valuesPrinted: false });
log({ event: "github-to-gitea-sync", repo: repo.key, ok: sync.ok, sourceCommit: sync.sourceCommit, snapshotRef: sync.snapshotRef, error: sync.error ? redact(sync.error) : null, elapsedMs: Date.now() - startedAt, valuesPrinted: false });
writeJson(res, sync.ok ? 200 : 500, { ok: sync.ok, event, repository, ref, repo: repo.key, ...sync, valuesPrinted: false });
} finally {
running.delete(repo.key);
@@ -136,6 +136,13 @@ function log(payload) {
console.log(JSON.stringify(payload));
}
function redact(value) {
return String(value || "")
.replace(/Authorization: Basic [A-Za-z0-9+/=]+/gu, "Authorization: Basic <redacted>")
.replace(/x-access-token:[^@\s]+/gu, "x-access-token:<redacted>")
.slice(-1600);
}
function requiredEnv(name) {
const value = process.env[name];
if (!value) throw new Error(`missing env ${name}`);