Skip to content

Commit 1805b8b

Browse files
committed
fix(domains): prevent empty logo strings in domain form submission
- Extract logo field separately for better validation - Add explicit type checking and whitespace trimming - Only include logo in payload when valid and changed - Prevents API validation error: 'Invalid image format' for empty strings Fixes issue where toggling Custom QR code logo switch would send empty string to API, causing unprocessable_entity error.
1 parent d13af21 commit 1805b8b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

apps/web/ui/domains/add-edit-domain-form.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,23 @@ export function AddEditDomainForm({
207207

208208
const onSubmit = async (formData: FormData) => {
209209
try {
210+
const { logo, ...restFormData } = formData;
211+
212+
const shouldIncludeLogo = Boolean(
213+
logo &&
214+
typeof logo === "string" &&
215+
logo.trim().length > 0 &&
216+
logo !== props?.logo,
217+
);
218+
210219
const res = await fetch(endpoint.url, {
211220
method: endpoint.method,
212221
headers: {
213222
"Content-Type": "application/json",
214223
},
215224
body: JSON.stringify({
216-
...formData,
217-
...(formData.logo === props?.logo && { logo: undefined }),
225+
...restFormData,
226+
...(shouldIncludeLogo && { logo }),
218227
...(formData.assetLinks && {
219228
assetLinks: sanitizeJson(formData.assetLinks),
220229
}),

0 commit comments

Comments
 (0)