Skip to content

Commit 44e855c

Browse files
anagarwaclaude
andauthored
fix(toc): cap scraping submissions at MAX_TOP_PAGES=200 (LLMO-5863) (#2731)
## Summary - `submitForScraping` in the TOC audit had no hard ceiling on the number of URLs sent to the scraper - The merged URL list (`auditTargetUrls → includedURLs → agenticUrls → topPagesUrls`) was submitted as-is; sites with large `includedURLs` or agentic URL lists could exceed the intended 200-URL budget - Added `topPages.slice(0, MAX_TOP_PAGES)` before building the scrape payload, mirroring the existing pattern in the summarization audit ## Changes - `src/toc/handler.js` — slice `topPages` to `MAX_TOP_PAGES` (200) in `submitForScraping` - `test/audits/toc.test.js` — new test: caps at 200 when 250 pages are supplied; 175 tests passing, 100% coverage on `src/toc` ## Test plan - [x] All existing TOC tests pass (175 passing) - [x] New test confirms only 200 URLs are returned when 250 are supplied - [x] `src/toc` coverage remains 100% lines/branches/statements - [x] `eslint src/toc/handler.js` — clean Jira: [LLMO-5863](https://jira.corp.adobe.com/browse/LLMO-5863) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2fea0c1 commit 44e855c

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/toc/handler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ export async function submitForScraping(context) {
352352
return { auditResult: terminalResult, fullAuditRef: site.getBaseURL() };
353353
}
354354

355-
log.info(`[TOC] Submitting ${topPages.length} URLs for scraping`);
355+
const pagesToScrape = topPages.slice(0, MAX_TOP_PAGES);
356+
log.info(`[TOC] Submitting ${pagesToScrape.length} URLs for scraping`);
356357
return {
357-
urls: topPages.map((url) => ({ url })),
358+
urls: pagesToScrape.map((url) => ({ url })),
358359
siteId: site.getId(),
359360
maxScrapeAge: 24,
360361
};

test/audits/toc.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3735,6 +3735,22 @@ describe('TOC (Table of Contents) Audit', () => {
37353735
expect(context.dataAccess.Audit.updateByKeys).to.have.been.calledOnce;
37363736
expect(logSpy.warn).to.have.been.calledWith('[TOC] No top pages found, ending audit');
37373737
});
3738+
3739+
it('caps submitted URLs at MAX_TOP_PAGES (200) when topPages exceeds the limit', async () => {
3740+
const logSpy = { info: sinon.spy(), error: sinon.spy(), debug: sinon.spy(), warn: sinon.spy() };
3741+
context.log = logSpy;
3742+
context.site = site;
3743+
const pages = Array.from({ length: 250 }, (_, i) => `https://example.com/page-${i}`);
3744+
context.audit = { getAuditResult: () => ({ success: true, topPages: pages }) };
3745+
3746+
const { submitForScraping } = await import('../../src/toc/handler.js');
3747+
const result = await submitForScraping(context);
3748+
3749+
expect(result.urls).to.have.lengthOf(200);
3750+
expect(result.urls[0]).to.deep.equal({ url: 'https://example.com/page-0' });
3751+
expect(result.urls[199]).to.deep.equal({ url: 'https://example.com/page-199' });
3752+
expect(logSpy.info).to.have.been.calledWith('[TOC] Submitting 200 URLs for scraping');
3753+
});
37383754
});
37393755
});
37403756

0 commit comments

Comments
 (0)