feat(photo-upload): Logging fuer Upload-Parse-Fehler
Some checks failed
Build & Publish Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build & Publish Docker Image / build-and-push (push) Has been cancelled
Der bisherige Endpoint verschluckte den formData()-Fehler mit einem generischen "Multipart erwartet" — wir wissen nicht, warum Chrome auf dem Tablet scheitert. Jetzt wird beim Fehler Content-Type, -Length und User-Agent geloggt, plus die konkrete Error-Message in der Response. Kein Foto-Inhalt im Log. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,16 +45,38 @@ export const POST: RequestHandler = async ({ request, getClientAddress }) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Header-Snapshot fuer Diagnose beim Upload-Parse-Fehler. Wir loggen
|
||||||
|
// Content-Type, -Length und User-Agent — nichts, was Inhalt verraet.
|
||||||
|
const contentType = request.headers.get('content-type') ?? '(missing)';
|
||||||
|
const contentLength = request.headers.get('content-length') ?? '(missing)';
|
||||||
|
const userAgent = request.headers.get('user-agent')?.slice(0, 120) ?? '(missing)';
|
||||||
|
|
||||||
let form: FormData;
|
let form: FormData;
|
||||||
try {
|
try {
|
||||||
form = await request.formData();
|
form = await request.formData();
|
||||||
} catch {
|
} catch (e) {
|
||||||
return errJson(400, 'BAD_REQUEST', 'Multipart body erwartet.');
|
const err = e as Error;
|
||||||
|
console.warn(
|
||||||
|
`[extract-from-photo] formData() failed: name=${err.name} msg=${err.message} ` +
|
||||||
|
`ct="${contentType}" len=${contentLength} ua="${userAgent}"`
|
||||||
|
);
|
||||||
|
return errJson(
|
||||||
|
400,
|
||||||
|
'BAD_REQUEST',
|
||||||
|
`Upload konnte nicht gelesen werden (${err.name}: ${err.message}).`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const photo = form.get('photo');
|
const photo = form.get('photo');
|
||||||
if (!(photo instanceof Blob)) {
|
if (!(photo instanceof Blob)) {
|
||||||
|
console.warn(
|
||||||
|
`[extract-from-photo] photo field missing or not a Blob. ct="${contentType}" ` +
|
||||||
|
`len=${contentLength} fields=${[...form.keys()].join(',')}`
|
||||||
|
);
|
||||||
return errJson(400, 'BAD_REQUEST', 'Feld "photo" fehlt.');
|
return errJson(400, 'BAD_REQUEST', 'Feld "photo" fehlt.');
|
||||||
}
|
}
|
||||||
|
console.info(
|
||||||
|
`[extract-from-photo] received photo size=${photo.size} mime="${photo.type}" ua="${userAgent}"`
|
||||||
|
);
|
||||||
if (photo.size > MAX_BYTES) {
|
if (photo.size > MAX_BYTES) {
|
||||||
return errJson(
|
return errJson(
|
||||||
413,
|
413,
|
||||||
|
|||||||
Reference in New Issue
Block a user