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:
parent
977f2bf98e
commit
1d0e4ee616
1 changed files with 7 additions and 1 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Reference in a new issue