fix(futo-backups-bot): fall back to a generic agent name when the profile read is forbidden (#584)

This commit is contained in:
Antoine Lecompte
2026-08-27 12:51:41 -07:00
committed by GitHub
parent 001da241f7
commit 7988ac3487
@@ -139,8 +139,10 @@ export class FreshdeskRepository {
if (cached) {
return cached;
}
const response = await this.request('GET', `/api/v2/agents/${agentId}`, undefined, [404]);
const name = response.status === 404 ? 'Support' : agentSchema.parse(await response.json()).contact.name;
// Reading other agents' profiles needs privileges the group-scoped bot
// key does not have — 403 falls back like 404 instead of failing ingest.
const response = await this.request('GET', `/api/v2/agents/${agentId}`, undefined, [403, 404]);
const name = response.ok ? agentSchema.parse(await response.json()).contact.name : 'Support';
this.agentNames.set(agentId, name);
return name;
}