From 78281e8bea0788e95f4bf26cdc9f5b4156bd1341 Mon Sep 17 00:00:00 2001 From: Oscar Madera <80536682+oscarbol09@users.noreply.github.com> Date: Tue, 21 Jul 2026 01:11:20 -0500 Subject: [PATCH] fix(jobdanmark): narrow soft-404 detection to avoid rejecting real postings (#206) The jobdanmark detail parser flagged a soft-404 by testing whether the page title contained the substring '404' anywhere, so a legitimate posting titled e.g. 'Room 404 Cleaner' was wrongly rejected as NOT_FOUND. Narrows title matching to startsWith('404') plus specific error phrases ('page not found', Danish 'siden blev ikke fundet'), keeping the existing body-text backstop. Verified: strictly reduces false-positives, the real 404-page title ('404 | Jobdanmark') still detected, tests pass network-free. By @oscarbol09. --- .../cli/src/commands/detail.ts | 9 ++++++++- .../cli/tests/detail-parsing.test.ts | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.agents/skills/jobdanmark-search/cli/src/commands/detail.ts b/.agents/skills/jobdanmark-search/cli/src/commands/detail.ts index 5a437eb..222889b 100644 --- a/.agents/skills/jobdanmark-search/cli/src/commands/detail.ts +++ b/.agents/skills/jobdanmark-search/cli/src/commands/detail.ts @@ -134,7 +134,14 @@ function overviewValue(root: ReturnType, label: string): string | function fromRenderedHtml(root: ReturnType, slug: string, url: string): DetailResult { const pageTitle = cleanText(root.querySelector("title")?.text ?? "") - if (pageTitle.toLowerCase().includes("404") || root.text.toLowerCase().includes("siden blev ikke fundet")) { + const titleLower = pageTitle.toLowerCase() + const bodyText = root.text.toLowerCase() + if ( + bodyText.includes("siden blev ikke fundet") || + titleLower.startsWith("404") || + titleLower.includes("page not found") || + titleLower.includes("siden blev ikke fundet") + ) { throw new Error("NOT_FOUND") } diff --git a/.agents/skills/jobdanmark-search/cli/tests/detail-parsing.test.ts b/.agents/skills/jobdanmark-search/cli/tests/detail-parsing.test.ts index e54bacb..ed8f453 100644 --- a/.agents/skills/jobdanmark-search/cli/tests/detail-parsing.test.ts +++ b/.agents/skills/jobdanmark-search/cli/tests/detail-parsing.test.ts @@ -49,4 +49,23 @@ describe("parseJobPostingFromHtml", () => { expect(parsed.description).toContain("identificere relevante datasæt"); expect(parsed.applyUrl).toBe("https://jfm.career.emply.com/da/apply/example"); }); + + test("does not reject titles containing '404' mid-phrase", () => { + const htmlWith404InTitle = HTML_WITHOUT_JSON_LD.replace( + "Journalistisk udvikler søges | jobdanmark", + "HTTP 404 Page Designer | jobdanmark", + ).replace( + '

Journalistisk udvikler søges

', + '

HTTP 404 Page Designer

', + ); + + const parsed = parseJobPostingFromHtml( + htmlWith404InTitle, + "http-404-designer", + "https://jobdanmark.dk/job/http-404-designer", + ); + + expect(parsed.title).toBe("HTTP 404 Page Designer"); + expect(parsed.hiringOrganization.name).toBe("JFM"); + }); });