fix: root files fall through until the backend has given a site answer

With the SEO backend unreachable since start, /robots.txt and /sitemap.xml
answered 503 where v0.1.1 left them to the app (a consumer's smoke expects
the app's 404). The root proxies now need a site answer; the last one seen
is kept while the backend is down, so a failure after it is still 503.
This commit is contained in:
Jakub Zych
2026-11-04 09:31:39 +01:00
parent c2357cd7f9
commit 6636cde70a
5 changed files with 32 additions and 22 deletions

View File

@@ -11,13 +11,15 @@ const ok: SeoSiteState = { state: 'ok', site: { root_files: ['google1234.html',
test('rootFileTargets: robots.txt, sitemap.xml, llms.txt and sitemap files go to the backend', () => {
assert.deepEqual(rootFileTargets('/robots.txt', ok, B, A), [{ kind: 'root', url: `${B}/robots.txt` }])
assert.deepEqual(rootFileTargets('/sitemap.xml?x=1', ok, B, A), [{ kind: 'root', url: `${B}/sitemap.xml` }])
assert.deepEqual(rootFileTargets('/llms.txt', { state: 'unknown' }, B, A), [{ kind: 'root', url: `${B}/llms.txt` }])
assert.deepEqual(rootFileTargets('/llms.txt', ok, B, A), [{ kind: 'root', url: `${B}/llms.txt` }])
assert.deepEqual(rootFileTargets('/sitemap-posts-1.xml', ok, B, A), [{ kind: 'sitemap', url: `${B}/_sitemap/files/sitemap-posts-1.xml` }])
})
test('rootFileTargets: an absent site answer (older backend) serves none of them', () => {
for (const p of ['/robots.txt', '/sitemap.xml', '/llms.txt', '/sitemap-posts-1.xml', '/google1234.html']) {
assert.equal(rootFileTargets(p, { state: 'absent' }, B, A), null, p)
test('rootFileTargets: without a site answer (older backend, or never reached) nothing is served, as in v0.1.1', () => {
for (const state of [{ state: 'absent' }, { state: 'unknown' }] as SeoSiteState[]) {
for (const p of ['/robots.txt', '/sitemap.xml', '/llms.txt', '/sitemap-posts-1.xml', '/google1234.html']) {
assert.equal(rootFileTargets(p, state, B, A), null, `${state.state} ${p}`)
}
}
})