Skip to content

refactor: improve logging on Factory download failure - #1686

Open
simonfernandes wants to merge 4 commits into
developfrom
fix-factory-failure-logging
Open

refactor: improve logging on Factory download failure#1686
simonfernandes wants to merge 4 commits into
developfrom
fix-factory-failure-logging

Conversation

@simonfernandes

@simonfernandes simonfernandes commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

  • Fixes errors being swallowed when tracing was enabled. The catch block would never throw and so the code continued until it errored trying to read a non existent stream which caused the ambiguous ERR_INVALID_ARG_TYPE error.
  • Improves the logging by including the error message from the factory.

Before:

[2026-07-23T12:02:59.395+01:00] ERROR - Failed to generate the requested file(s)
{"err":{"error":{"code":"ERR_INVALID_ARG_TYPE"},"message":"Could not download generated pdf/proposal"},"originalUrl":"/download/pdf/proposal/31754"

After:

[2026-07-28T17:19:27.448+01:00] ERROR - Factory service failed to generate pdf/proposal: Could not create readable stream
error: large object 628393 does not exist undefined
{"exception":{"name":"Error","message":"Factory service failed to generate pdf/proposal: Could not create readable stream \nerror: large object 628393 does not exist undefined",

Motivation and Context

We see this vague error occasionally in logs at STFC and it is useful for diagnosing problems.

How Has This Been Tested

Manual testing checking logs with tracing enabled and disabled.

Fixes

UserOfficeProject/issue-tracker#1636

Changes

  • A new function throwFactoryError is introduced to handle Factory download failures. It provides more detailed error messages, including the download type and the exact error message from the Factory service.
  • The error handling in callFactoryService function has been updated to use the new throwFactoryError function.
  • The error logging in the Factory middleware has been enhanced to log the underlying error along with its message, providing more context for debugging.

Depends on

Tests included/Docs Updated?

  • I have added tests to cover my changes.
  • All relevant doc has been updated

@simonfernandes
simonfernandes requested review from a team and bolmsten and removed request for a team July 28, 2026 16:30
@simonfernandes
simonfernandes requested a review from a team as a code owner July 28, 2026 16:30
@simonfernandes
simonfernandes requested review from EdwardHaynes and Junjiequan and removed request for a team July 28, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants