Compare commits

...
Author SHA1 Message Date
Sonarly Claude CodeandClaude Opus 4.6 897e9643c9 fix: coerce address lat/lng to numbers before persisting
Address field values loaded from the store or returned from the geocoding
API can contain latitude and longitude as strings (e.g. "52.838...").
The Zod validation schema in isFieldAddressValue expects z.number().nullable(),
so string coordinates cause validation to fail, throwing "Invalid value to
persist" and blocking address field edits.

Add a parseCoordinate helper in convertToAddress that coerces string lat/lng
values to numbers (via Number()) before the value is passed to the persist
layer, ensuring the Zod validation succeeds.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-19 23:26:04 +00:00
@@ -18,6 +18,12 @@ export const AddressFieldInput = () => {
const convertToAddress = (
newAddress: FieldAddressDraftValue | undefined,
): FieldAddressDraftValue => {
const parseCoordinate = (value: number | string | null | undefined): number | null => {
if (value == null) return null;
const num = Number(value);
return Number.isFinite(num) ? num : null;
};
return {
addressStreet1: newAddress?.addressStreet1 ?? '',
addressStreet2: newAddress?.addressStreet2 ?? null,
@@ -25,8 +31,8 @@ export const AddressFieldInput = () => {
addressState: newAddress?.addressState ?? null,
addressCountry: newAddress?.addressCountry ?? null,
addressPostcode: newAddress?.addressPostcode ?? null,
addressLat: newAddress?.addressLat ?? null,
addressLng: newAddress?.addressLng ?? null,
addressLat: parseCoordinate(newAddress?.addressLat),
addressLng: parseCoordinate(newAddress?.addressLng),
};
};
const settings = fieldDefinition.metadata.settings;