fix: gitea mcp issues
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 4s
Monorepo Pipeline / 🧪 Test (push) Successful in 1m41s
Monorepo Pipeline / 🧹 Lint (push) Successful in 5m17s
Monorepo Pipeline / 🏗️ Build (push) Successful in 4m16s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
🏥 Server Maintenance / 🧹 Prune & Clean (push) Failing after 5s

This commit is contained in:
2026-03-12 13:33:10 +01:00
parent fbfc9feab0
commit 2a9c5780c3

View File

@@ -562,14 +562,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
jobs.map(async (job: any) => { jobs.map(async (job: any) => {
let console_log = undefined; let console_log = undefined;
// Fetch log text if job failed to provide context // Fetch log text for failed, running, or stuck jobs
if (job.conclusion === "failure" || job.status === "failure") { if (
job.conclusion === "failure" ||
job.status === "failure" ||
job.status === "in_progress" ||
job.status === "running"
) {
try { try {
const logResponse = await giteaClient.get( const logResponse = await giteaClient.get(
`/repos/${owner}/${repo}/actions/jobs/${job.id}/logs`, `/repos/${owner}/${repo}/actions/jobs/${job.id}/logs`,
); );
if (typeof logResponse.data === "string") { if (typeof logResponse.data === "string") {
let fullLog = logResponse.data; let fullLog = logResponse.data;
// First, truncate to 20000 characters to prevent OOM / regex crashes on multi-megabyte strings and avoid docker exec pipe buffer limits
if (fullLog.length > 20000) {
fullLog = "...[truncated]...\n" + fullLog.slice(-20000);
}
// Strip ANSI escape codes // Strip ANSI escape codes
fullLog = fullLog.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, ""); fullLog = fullLog.replace(/\x1B\[[0-9;]*[a-zA-Z]/g, "");
@@ -577,10 +588,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
// DO NOT strip characters > 0x7F, as they are part of valid UTF-8 multibyte characters (like emojis 🧹). // DO NOT strip characters > 0x7F, as they are part of valid UTF-8 multibyte characters (like emojis 🧹).
fullLog = fullLog.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, ""); fullLog = fullLog.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, "");
// Truncate to 10000 characters to prevent message size limits
if (fullLog.length > 10000) {
fullLog = "...[truncated]...\n" + fullLog.slice(-10000);
}
console_log = fullLog; console_log = fullLog;
} }
} catch (err: any) { } catch (err: any) {