Fix crash when Claude returns hours as object instead of string

parseHoursString expected a string but Claude AI sometimes returns
structured hours data as an object. Now normalizes to string first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-03-14 13:01:22 -07:00
parent 977f2bf98e
commit 1d0e4ee616

View file

@ -2152,7 +2152,13 @@
console.log('Parsed address:', { addressLine1, city, state, zip });
// Parse hours into a 7-day schedule
const hoursSchedule = parseHoursString(biz.hours || '');
// Claude may return hours as an object or string — normalize to string
let hoursRaw = biz.hours || '';
if (typeof hoursRaw === 'object') {
// Try to flatten object to readable string (e.g. { monday: "9am-5pm", ... })
try { hoursRaw = Object.entries(hoursRaw).map(([k, v]) => `${k} ${v}`).join(', '); } catch (e) { hoursRaw = ''; }
}
const hoursSchedule = parseHoursString(String(hoursRaw));
addMessage('ai', `
<p>I found your restaurant information:</p>