mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: resolve 20 Sentry issues and fix navbar test flakiness
Sentry fixes: - Only send 5xx errors to Sentry (was sending 4xx rate-limit, media type errors) - Encode non-ASCII chars in X-Output-Filename header (encodeURIComponent) - Handle FK constraint failures gracefully in file upload, pipeline save, API keys - Harden getDirSize against ENOENT race on readdirSync Test fixes: - Wrap navbar test renders in act() to flush async useEffect state updates - Add useEffect cleanup to navbar to prevent state updates on unmounted component - Fixes timeout when running in full test suite
This commit is contained in:
@@ -198,21 +198,25 @@ export async function userFileRoutes(app: FastifyInstance): Promise<void> {
|
||||
|
||||
// Create DB record
|
||||
const id = randomUUID();
|
||||
db.insert(schema.userFiles)
|
||||
.values({
|
||||
id,
|
||||
userId,
|
||||
originalName: safeName,
|
||||
storedName,
|
||||
mimeType,
|
||||
size: safeBuffer.length,
|
||||
width: validation.width,
|
||||
height: validation.height,
|
||||
version: 1,
|
||||
parentId: null,
|
||||
toolChain: null,
|
||||
})
|
||||
.run();
|
||||
try {
|
||||
db.insert(schema.userFiles)
|
||||
.values({
|
||||
id,
|
||||
userId,
|
||||
originalName: safeName,
|
||||
storedName,
|
||||
mimeType,
|
||||
size: safeBuffer.length,
|
||||
width: validation.width,
|
||||
height: validation.height,
|
||||
version: 1,
|
||||
parentId: null,
|
||||
toolChain: null,
|
||||
})
|
||||
.run();
|
||||
} catch {
|
||||
return reply.status(409).send({ error: "Failed to save file record" });
|
||||
}
|
||||
|
||||
const row = db.select().from(schema.userFiles).where(eq(schema.userFiles.id, id)).get();
|
||||
|
||||
@@ -555,21 +559,25 @@ export async function userFileRoutes(app: FastifyInstance): Promise<void> {
|
||||
|
||||
// Create DB record
|
||||
const id = randomUUID();
|
||||
db.insert(schema.userFiles)
|
||||
.values({
|
||||
id,
|
||||
userId,
|
||||
originalName: resultName,
|
||||
storedName,
|
||||
mimeType,
|
||||
size: safeResultBuffer.length,
|
||||
width: validation.width,
|
||||
height: validation.height,
|
||||
version: nextVersion,
|
||||
parentId,
|
||||
toolChain: JSON.stringify(newChain),
|
||||
})
|
||||
.run();
|
||||
try {
|
||||
db.insert(schema.userFiles)
|
||||
.values({
|
||||
id,
|
||||
userId,
|
||||
originalName: resultName,
|
||||
storedName,
|
||||
mimeType,
|
||||
size: safeResultBuffer.length,
|
||||
width: validation.width,
|
||||
height: validation.height,
|
||||
version: nextVersion,
|
||||
parentId,
|
||||
toolChain: JSON.stringify(newChain),
|
||||
})
|
||||
.run();
|
||||
} catch {
|
||||
return reply.status(409).send({ error: "Failed to save result record" });
|
||||
}
|
||||
|
||||
const row = db.select().from(schema.userFiles).where(eq(schema.userFiles.id, id)).get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user