mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-07 05:09:18 -05:00
[PR #2522] [CLOSED] fix: logo URL validation shows cryptic error instead of meaningful message #7812
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/pangolin/pull/2522
Author: @shreyaspapi
Created: 2/23/2026
Status: ❌ Closed
Base:
main← Head:fix/2325-logo-url-validation📝 Commits (1)
0992ee4fix: replace z.union with inline empty string check in logo URL validation📊 Changes
2 files changed (+125 additions, -122 deletions)
View changed files
📝
server/private/routers/loginPage/upsertLoginPageBranding.ts(+68 -64)📝
src/components/AuthPageBrandingForm.tsx(+57 -58)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Summary
Fixes #2325
z.union([z.literal(""), z.string().superRefine(...)])with a singlez.string().superRefine(...)that handles the empty string case internallyAuthPageBrandingForm.tsx) and server-side (upsertLoginPageBranding.ts) validation schemasProblem
When entering a logo URL that fails validation (e.g., the server doesn't return an
image/*content-type), users see the cryptic error:This happens because Zod's
z.uniontries all branches when one fails. The first branch (z.literal("")) expects an empty string, so its error message about<=0 charactersgets surfaced instead of the actual validation error from thesuperRefinebranch.Fix
Move the empty string check inside the
superRefinecallback as an early return. This eliminates thez.unionentirely, so validation errors (invalid URL, non-image content-type, network errors, etc.) are always reported directly to the user.How to test?
All existing validation cases are preserved:
"Must be a valid URL""Failed to load image...""URL does not point to an image..."🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.