Skip to content

/analyze endpoint swallows errors — no logging, generic error message #37

@vzegnameta

Description

@vzegnameta

/analyze endpoint swallows errors — no logging, generic error message

Description

The /analyze REST endpoint catches all exceptions but doesn't log them. The catch block at src/transports/http.ts:48-52 returns a generic {"error": "<message>"} response with no console.error, making it impossible to diagnose failures from server logs (e.g. Cloud Run, Docker).

Current behavior

} catch (error) {
    const message = error instanceof Error ? error.message : "Unknown error";
    res.writeHead(500, { "Content-Type": "application/json" });
    res.end(JSON.stringify({ error: message }));
}
  • No stdout/stderr output on error
  • Cloud Run logs show only POST 500 with no traceback
  • Root cause is invisible without modifying the code

Proposed fix

Add console.error before the response:

} catch (error) {
    console.error("[/analyze] Error processing PDF:", error);
    const message = error instanceof Error ? error.message : "Unknown error";
    res.writeHead(500, { "Content-Type": "application/json" });
    res.end(JSON.stringify({ error: message }));
}

Impact

One-line change. No behavior change for API consumers — same response format. Server operators can now see the full error + stack trace in logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions