From 56ca58dc0bc4569073f4f12d1c7388d2b23a6739 Mon Sep 17 00:00:00 2001 From: dhavkuma Date: Wed, 15 Jul 2026 19:12:14 +0530 Subject: [PATCH] feat(config): add excludedPathPrefixes support to handlers config Add Joi schema field, getter, and setter for excludedPathPrefixes in the site handler config. This allows sites to specify path prefixes to exclude from audit scope, solving the subpath sibling site overlap issue (LLMO-6132). Co-Authored-By: Claude Sonnet 4.6 --- .../src/models/site/config.js | 8 ++++++++ .../test/unit/models/site/config.test.js | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/packages/spacecat-shared-data-access/src/models/site/config.js b/packages/spacecat-shared-data-access/src/models/site/config.js index d56f4d1f2..2df515796 100644 --- a/packages/spacecat-shared-data-access/src/models/site/config.js +++ b/packages/spacecat-shared-data-access/src/models/site/config.js @@ -495,6 +495,7 @@ export const configSchema = Joi.object({ mentions: Joi.object().pattern(Joi.string(), Joi.array().items(Joi.string())), excludedURLs: Joi.array().items(Joi.string()), autofixExcludedURLs: Joi.array().items(Joi.string()), + excludedPathPrefixes: Joi.array().items(Joi.string()), manualOverwrites: Joi.array().items(Joi.object({ brokenTargetURL: Joi.string().optional(), targetURL: Joi.string().optional(), @@ -577,6 +578,7 @@ export const Config = (data = {}) => { self.getImports = () => state.imports; self.getExcludedURLs = (type) => state?.handlers?.[type]?.excludedURLs; self.getAutofixExcludedURLs = (type) => state?.handlers?.[type]?.autofixExcludedURLs; + self.getExcludedPathPrefixes = (type) => state?.handlers?.[type]?.excludedPathPrefixes; self.getManualOverwrites = (type) => state?.handlers?.[type]?.manualOverwrites; self.getFixedURLs = (type) => state?.handlers?.[type]?.fixedURLs; self.getIncludedURLs = (type) => state?.handlers?.[type]?.includedURLs; @@ -882,6 +884,12 @@ export const Config = (data = {}) => { state.handlers[type].autofixExcludedURLs = autofixExcludedURLs; }; + self.updateExcludedPathPrefixes = (type, excludedPathPrefixes) => { + state.handlers = state.handlers || {}; + state.handlers[type] = state.handlers[type] || {}; + state.handlers[type].excludedPathPrefixes = excludedPathPrefixes; + }; + self.updateManualOverwrites = (type, manualOverwrites) => { state.handlers = state.handlers || {}; state.handlers[type] = state.handlers[type] || {}; diff --git a/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js b/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js index cd09a311e..413a2266d 100644 --- a/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js +++ b/packages/spacecat-shared-data-access/test/unit/models/site/config.test.js @@ -413,6 +413,19 @@ describe('Config Tests', () => { expect(config.getAutofixExcludedURLs('non-existent-handler')).to.be.undefined; }); + it('correctly updates the excluded path prefixes', () => { + const config = Config(); + config.updateExcludedPathPrefixes('prerender', ['/jp/ja', '/de/de']); + + const excludedPathPrefixes = config.getExcludedPathPrefixes('prerender'); + expect(excludedPathPrefixes).to.deep.equal(['/jp/ja', '/de/de']); + }); + + it('returns undefined for excluded path prefixes when handler is not present', () => { + const config = Config(); + expect(config.getExcludedPathPrefixes('non-existent-handler')).to.be.undefined; + }); + it('correctly updates the manual overrides', () => { const config = Config(); const manualOverwrites = [ @@ -476,6 +489,7 @@ describe('Config Tests', () => { expect(config.getHandlerConfig('404')).to.be.undefined; expect(config.getExcludedURLs('404')).to.be.undefined; expect(config.getAutofixExcludedURLs('404')).to.be.undefined; + expect(config.getExcludedPathPrefixes('404')).to.be.undefined; expect(config.getManualOverwrites('404')).to.be.undefined; expect(config.getFixedURLs('404')).to.be.undefined; expect(config.getIncludedURLs('404')).to.be.undefined;