[Fix] Surface API errors in logs and return MCP validation failures as 400s - #988
Merged
Conversation
Contributor
|
No new code issues found. See task
Reviewed 6acd98c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
apps/api/src/server.ts: the app-levelonErrorhandler now logs unexpected errors server-side (console.errorwith request method, path, and the error with stack) before responding, for bothHTTPException>= 500 and generic errors. Sentry capture is unchanged.apps/api/src/handlers/custom-automations/index.ts: the create, update, and resolve-schedule MCP routes now translate expected validation failures thrown as plainErrors (missing environment, cron/schedule validation, automation cap, target configuration, etc.) into400responses carrying the message. Postgres duplicate-name unique violations (code23505oncustom_automations_name_unique_idx, including drizzle-wrapped causes) return a friendly "A custom automation with this name already exists." message. Anything not on the known-pattern allowlist is rethrown so the app-level handler logs it and returns an opaque 500.apps/api/src/handlers/custom-automations/__tests__/custom-automations-routes.test.tscovering the 400 translations (missing environment, duplicate name direct and cause-wrapped, automation cap, schedule validation) and the rethrow-to-500 path for create, update, and resolve-schedule.Why this change was made
captureApiExceptionis a no-op in that case.internal_server_errorfor expected validation failures, so the calling agent could not see what was wrong or self-correct. The web tRPC layer already surfaces these same messages to admins.Impact
manage_custom_automationsget actionable 400 messages for expected failures instead of opaque 500s; truly unexpected errors still return 500 and are now logged.