Skip to content

Commit 1846a37

Browse files
noelruiz34claude
andcommitted
fix(LLMO-4070): guard against null configuration in patchAuditForSite
Configuration.findLatest() returns null when no config exists in S3 (NoSuchKey case). Calling .getHandlers() on null threw a TypeError, surfacing as a 500 in environments where the config bucket exists but has no object (IT test VPC environment). Skip the audit-type validation when no configuration is available — in production the config is always present. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c0d92c3 commit 1846a37

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/controllers/audits.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,12 @@ function AuditsController(ctx) {
219219
}
220220

221221
const configuration = await Configuration.findLatest();
222-
const registeredAudits = configuration.getHandlers();
223-
if (!registeredAudits[auditType]) {
224-
return notFound(`The "${auditType}" is not present in the configuration. List of allowed audits:`
225-
+ ` ${Object.keys(registeredAudits).join(', ')}.`);
222+
if (configuration) {
223+
const registeredAudits = configuration.getHandlers();
224+
if (!registeredAudits[auditType]) {
225+
return notFound(`The "${auditType}" is not present in the configuration. List of allowed audits:`
226+
+ ` ${Object.keys(registeredAudits).join(', ')}.`);
227+
}
226228
}
227229

228230
const siteConfig = site.getConfig();

0 commit comments

Comments
 (0)