Harden workflow route against sharer enrichment crashes

An async rejection during sharer-name enrichment could crash the Express 4 process rather than return a 500. willchen96 wrapped the route handlers, made the enrichment lookups non-fatal, and replaced a broad `listUsers` call with targeted per-ID fetches.

workflowinfrastructure

The root problem is an Express 4 behavior: an async route handler that rejects without a try/catch escapes normal error middleware and can take down the process. The fix wraps the workflow listing route's async handlers and adds route-level error middleware that converts unhandled rejections into 500 responses.

The sharer enrichment path was also made fail-closed. If a profile or email lookup fails, the workflow listing still returns - the enrichment result is advisory. More consequentially, the previous implementation called listUsers which pages through up to a thousand auth records to find sharer identities. The replacement does targeted lookups against only the user IDs actually referenced by the visible workflows. Cost and latency now scale with the request rather than with total account size.

A smaller thread in the same PR standardizes LLM provider error surfaces. Gemini, OpenAI, and Anthropic call sites now raise explicit errors when API keys are missing, before a provider call is attempted. The failure message now names the missing variable rather than propagating an opaque downstream error.

So what Worth pulling if you run shared workflows and care about process stability. The `listUsers` swap is also worth taking independently - if your deployment has more than a few hundred users, the difference in latency on the workflow listing endpoint will be noticeable.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

2 commits from willchen96/mike, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
a2368a74 refactor: enhance error handling and streamline API key management in LLM modules willchen96 2026-05-14 ↗ GitHub
9e7046d4 Merge pull request #132 from willchen96/project-page-deployment-fixes cosimoastrada 2026-05-14 ↗ GitHub
refactor: enhance error handling and streamline API key management in LLM modules

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-478.md from inside the repo you want the changes in.

⬇ Download capture-thread-478.md