Skip to content

Tag upstream API errors at error level with service/upstreamStatus/at…#848

Open
swdpcomputing wants to merge 4 commits intomainfrom
bugfix/TGC-1057-logging-be-502-to-fe-500
Open

Tag upstream API errors at error level with service/upstreamStatus/at…#848
swdpcomputing wants to merge 4 commits intomainfrom
bugfix/TGC-1057-logging-be-502-to-fe-500

Conversation

@swdpcomputing
Copy link
Copy Markdown
Contributor

When grants-ui-backend goes down (like the failed deployment in dev that returned 502s), grants-ui in front of it returns a 500. The logs say "the BE is the cause" and are emitted at debug level and don't include the upstream HTTP status or which service had failed, so they were filtered out by default and nobody knew why grants-ui was 500ing.

This PR:

  1. Tags every outgoing-call error with structured felds. Every call to grants-ui-backend, GAS, agreements, or consolidated-view now logs service, upstreamStatus, and (on retry-exhaustion) attempts.

  2. Promotes those logs from debug to error level. The previous debug() wrapper forced everything down to debug regardless of declared level. This swaps to log() which respects the declared level.

So now an alert query like level=error AND service=grants-ui-backend AND upstreamStatus>=500 now matches the next time the BE fails, so we hear about it. User-facing behaviour is unchanged, the 500 page still renders. The alerting-channel investigation (second half of the ticket) is a separate config task.

@swdpcomputing swdpcomputing requested a review from a team April 29, 2026 11:38
@swdpcomputing swdpcomputing force-pushed the bugfix/TGC-1057-logging-be-502-to-fe-500 branch from d9ccd63 to d83cbce Compare April 29, 2026 12:48
@swdpcomputing swdpcomputing force-pushed the bugfix/TGC-1057-logging-be-502-to-fe-500 branch from b3d601a to 09908b6 Compare April 29, 2026 14:33
@swdpcomputing swdpcomputing force-pushed the bugfix/TGC-1057-logging-be-502-to-fe-500 branch from 09908b6 to 28a12bc Compare April 30, 2026 07:50
@sonarqubecloud
Copy link
Copy Markdown

return apiResponse
} catch (error) {
debug(LogCodes.SYSTEM.EXTERNAL_API_ERROR, { endpoint: 'agreements', errorMessage: error.message }, request)
logAgreementsUpstreamError(request, error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this one 😂 clearly trying to get around the ESLint rule by encapsulating the log in another function. Let's discuss this with @alanplatt, as it might be wrong to wholly deny log in catch blocks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not dodging the rule! log/logger are already on the exclude list in eslint.config.js. Pulled it into a helper because the payload got chunky. Same shape as handleVerificationError in verify-token.js. Happy to inline it, or chat with Alan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants