[GH-ISSUE #2486] [Bug]: Recipient search throws 500 Internal Server Error due to output validation #693

Open
opened 2026-02-26 18:48:05 +03:00 by kerem · 2 comments
Owner

Originally created by @abdulalim110 on GitHub (Feb 12, 2026).
Original GitHub issue: https://github.com/documenso/documenso/issues/2486

Issue Description

Title:
[Bug]: Recipient search throws 500 Internal Server Error due to output validation

Body:

Describe the bug
The recipient autocomplete functionality crashes with a 500 Internal Server Error on Production (app.documenso.com) when the search results contain recipients with non-standard or "draft" email formats (e.g., "new", "test", or invalid emails).

To Reproduce
Steps to reproduce the behavior:

  1. Go to the 'Send Document' flow.
  2. Click on 'Add Recipient'.
  3. Type a query that matches a recipient with an invalid email format (e.g. "new").
  4. The API request to recipient.suggestions.find fails with status 500.

Expected behavior
The search should return the matching recipients (even if they have invalid/draft emails) without crashing the application.

Evidence

https://github.com/user-attachments/assets/1356f594-13b8-4bf2-928a-5c4039b65f4c

Additional Context
Based on the server logs, this appears to be caused by a Zod Output Validation failure.
The ZGetRecipientSuggestionsResponseSchema enforces z.string().email(), but the application logic allows creating recipients with invalid emails (e.g. for placeholders/drafts). When these records are returned in search, the strict schema validation throws an internal error.

I have a fix ready (relaxing the output schema validation) and will submit a PR shortly.

Steps to Reproduce

  1. Log in to the application (tested on app.documenso.com).
  2. Navigate to the "Send Document" flow and upload any document.
  3. Proceed to the "Add Recipient" step.
  4. Click on the recipient input field to trigger the search/autocomplete.
  5. Type a query that matches a recipient with a draft or non-standard email format (e.g., type "new", "test", or any string that matches a placeholder email in the database).
  6. Observe the Network tab in Developer Tools.

Expected Behavior

The search API should return the matching recipients (including those with draft/placeholder emails) without crashing. The UI should display the suggestions list normally.

Current Behavior

The API request to recipient.suggestions.find fails with a 500 Internal Server Error.
The UI gets stuck in a loading state or fails to show results.

Technical Context:
Server logs indicate an Output validation failed error. This happens because the ZGetRecipientSuggestionsResponseSchema strictly enforces z.string().email(), but the application logic allows creating recipients with invalid/placeholder emails (e.g. for drafts). When these records are returned in search, the strict schema validation throws an internal error.

Screenshots (optional)

Image

Operating System [e.g., Windows 10]

Windows 11

Browser [e.g., Chrome, Firefox]

Chrome

Version [e.g., 2.0.1]

app.documenso.com

Please check the boxes that apply to this issue report.

  • I have searched the existing issues to make sure this is not a duplicate.
  • I have provided steps to reproduce the issue.
  • I have included relevant environment information.
  • I have included any relevant screenshots.
  • I understand that this is a voluntary contribution and that there is no guarantee of resolution.
  • I want to work on creating a PR for this issue if approved
Originally created by @abdulalim110 on GitHub (Feb 12, 2026). Original GitHub issue: https://github.com/documenso/documenso/issues/2486 ### Issue Description **Title:** `[Bug]: Recipient search throws 500 Internal Server Error due to output validation` **Body:** **Describe the bug** The recipient autocomplete functionality crashes with a `500 Internal Server Error` on Production (`app.documenso.com`) when the search results contain recipients with non-standard or "draft" email formats (e.g., "new", "test", or invalid emails). **To Reproduce** Steps to reproduce the behavior: 1. Go to the 'Send Document' flow. 2. Click on 'Add Recipient'. 3. Type a query that matches a recipient with an invalid email format (e.g. "new"). 4. The API request to `recipient.suggestions.find` fails with status 500. **Expected behavior** The search should return the matching recipients (even if they have invalid/draft emails) without crashing the application. **Evidence** https://github.com/user-attachments/assets/1356f594-13b8-4bf2-928a-5c4039b65f4c **Additional Context** Based on the server logs, this appears to be caused by a **Zod Output Validation** failure. The `ZGetRecipientSuggestionsResponseSchema` enforces `z.string().email()`, but the application logic allows creating recipients with invalid emails (e.g. for placeholders/drafts). When these records are returned in search, the strict schema validation throws an internal error. I have a fix ready (relaxing the output schema validation) and will submit a PR shortly. ### Steps to Reproduce 1. Log in to the application (tested on `app.documenso.com`). 2. Navigate to the **"Send Document"** flow and upload any document. 3. Proceed to the **"Add Recipient"** step. 4. Click on the recipient input field to trigger the search/autocomplete. 5. Type a query that matches a recipient with a draft or non-standard email format (e.g., type "new", "test", or any string that matches a placeholder email in the database). 6. Observe the Network tab in Developer Tools. ### Expected Behavior The search API should return the matching recipients (including those with draft/placeholder emails) without crashing. The UI should display the suggestions list normally. ### Current Behavior The API request to `recipient.suggestions.find` fails with a **500 Internal Server Error**. The UI gets stuck in a loading state or fails to show results. **Technical Context:** Server logs indicate an `Output validation failed` error. This happens because the `ZGetRecipientSuggestionsResponseSchema` strictly enforces `z.string().email()`, but the application logic allows creating recipients with invalid/placeholder emails (e.g. for drafts). When these records are returned in search, the strict schema validation throws an internal error. ### Screenshots (optional) <img width="1624" height="874" alt="Image" src="https://github.com/user-attachments/assets/7ca35fb0-af0d-4ca9-a1db-62dd1a26c086" /> ### Operating System [e.g., Windows 10] Windows 11 ### Browser [e.g., Chrome, Firefox] Chrome ### Version [e.g., 2.0.1] app.documenso.com ### Please check the boxes that apply to this issue report. - [x] I have searched the existing issues to make sure this is not a duplicate. - [x] I have provided steps to reproduce the issue. - [x] I have included relevant environment information. - [x] I have included any relevant screenshots. - [x] I understand that this is a voluntary contribution and that there is no guarantee of resolution. - [x] I want to work on creating a PR for this issue if approved
Author
Owner

@catalinpit commented on GitHub (Feb 13, 2026):

Thanks for opening the issue! I followed your steps and can't replicate the issue. z.string().email() should stay as it is.

LE: Ok, I played with it a bit more. The error happens when you add a recipient name that doesn't exist.

https://github.com/user-attachments/assets/dcd90643-3fdc-405d-9e47-d74be8dc9fc3

<!-- gh-comment-id:3895098934 --> @catalinpit commented on GitHub (Feb 13, 2026): Thanks for opening the issue! I followed your steps and can't replicate the issue. `z.string().email()` should stay as it is. LE: Ok, I played with it a bit more. The error happens when you add a recipient name that doesn't exist. https://github.com/user-attachments/assets/dcd90643-3fdc-405d-9e47-d74be8dc9fc3
Author
Owner

@abdulalim110 commented on GitHub (Feb 13, 2026):

Nice catch on the repro @catalinpit

Saw the 500 error on recipient.suggestions.find in the video. Since it crashes when the recipient doesn't exist, we should handle that lookup gracefully (e.g. return empty) instead of throwing a 500.

Mind if I open a new PR to fix just this logic? I'll keep the schema strict as requested

<!-- gh-comment-id:3895261680 --> @abdulalim110 commented on GitHub (Feb 13, 2026): Nice catch on the repro @catalinpit Saw the 500 error on recipient.suggestions.find in the video. Since it crashes when the recipient doesn't exist, we should handle that lookup gracefully (e.g. return empty) instead of throwing a 500. Mind if I open a new PR to fix just this logic? I'll keep the schema strict as requested
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#693
No description provided.