Harden Homarr provider limits

This commit is contained in:
ajnart committed 2026-08-11 22:53:49 +02:00
1 parent 47c349bcd4
commit 0774b02878
14 files changed
+463 -459

No files matched your search

@@ -72,6 +72,7 @@ export const maxDuration = 300;
const assistantRequestMaxBytes = 12_000_000;
const logger = createLogger({ module: "assistant" });
const getAssistantLogErrorType = (error: unknown) => (error instanceof Error ? error.name : typeof error);
const getToolApprovalSecret = () =>
Buffer.from(
hkdfSync("sha256", Buffer.from(env.SECRET_ENCRYPTION_KEY, "hex"), "", "assistant-tool-approval", 32),
@@ -435,7 +436,7 @@ export async function POST(request: Request) {
} catch (error) {
logger.warn("Rejected an unsafe Homarr provider endpoint", {
provider: configuration.provider,
error,
errorType: getAssistantLogErrorType(error),
});
return Response.json({ error: "The Homarr provider endpoint is not configured safely." }, { status: 503 });
}
@@ -462,7 +463,7 @@ export async function POST(request: Request) {
requestId,
provider: configuration.provider,
modelId: requestedModelId,
error: modelLookup.error,
errorType: getAssistantLogErrorType(modelLookup.error),
});
}
const selectedModel = modelLookup.model;
@@ -536,7 +537,7 @@ export async function POST(request: Request) {
} catch (error) {
logger.error("Assistant tool call failed", {
toolName: mcpTool.name,
error: error instanceof Error ? error.message : String(error),
errorType: getAssistantLogErrorType(error),
});
return { error: getSafeAssistantToolError(error, { toolName: mcpTool.name }) };
}
@@ -747,7 +748,7 @@ export async function POST(request: Request) {
requestId,
provider: configuration.provider,
modelId,
error: error instanceof Error ? error.message : String(error),
errorType: getAssistantLogErrorType(error),
});
},
onFinish: async () => {
@@ -759,7 +760,7 @@ export async function POST(request: Request) {
} catch (error) {
logger.error("Failed to update assistant conversation metadata", {
threadId: thread.id,
error: error instanceof Error ? error.message : String(error),
errorType: getAssistantLogErrorType(error),
});
}
},
@@ -866,7 +867,7 @@ export async function POST(request: Request) {
});
} catch (error) {
logger.error("Assistant response could not start", {
error: error instanceof Error ? error.message : String(error),
errorType: getAssistantLogErrorType(error),
});
return Response.json(
{