Skip to content

Commit bc7002e

Browse files
committed
fix: do not cache transient malformed parent POM responses
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 085a382 commit bc7002e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • services/apps/packages_worker/src/security-contacts/extractors/registry

services/apps/packages_worker/src/security-contacts/extractors/registry/maven.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,15 @@ async function fetchParentPom(
196196
): Promise<ParentPom | null> {
197197
const groupPath = ref.group.replace(/\./g, '/')
198198
const url = `${BASE}/${groupPath}/${ref.artifact}/${ref.version}/${ref.artifact}-${ref.version}.pom`
199-
const { text } = await fetchText(url, timeoutMs, registryHeaders(userAgent))
200-
if (!text) return null
199+
const { status, text } = await fetchText(url, timeoutMs, registryHeaders(userAgent))
200+
// null only for genuinely-absent statuses (immutable gav → safe to negative-cache); a 200
201+
// with an empty or unparseable body is treated as an error so the cache evicts it.
202+
if (!text) {
203+
if (status === 200) throw new Error(`empty parent POM body: ${url}`)
204+
return null
205+
}
201206
const project = parseProject(text)
202-
if (!project) return null
207+
if (!project) throw new Error(`unparseable parent POM: ${url}`)
203208
const fetchedAt = new Date().toISOString()
204209
return {
205210
group: typeof project.groupId === 'string' ? project.groupId : ref.group,

0 commit comments

Comments
 (0)