From c0e3139503a1d933d5356985ff65ed85549eb08c Mon Sep 17 00:00:00 2001 From: Jordan Ramos Date: Tue, 16 Jun 2026 15:45:43 -0600 Subject: [PATCH] =?UTF-8?q?Fix=20atlas=5Fknown=20=E2=80=94=20parse=20respo?= =?UTF-8?q?nse=20body=20to=20detect=20'not=20found'=20hosts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of blanket-marking managed BU hosts, now parses the Atlas API response: if it returns a valid {active, inactive} structure, the host is known. If it returns an error or 'not found' message (even with a 2xx status), the host is not known and won't show a badge. This prevents the shield showing on hosts Atlas doesn't actually track, while correctly showing it on hosts Atlas recognizes (with or without plans). --- backend/routes/atlas.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/backend/routes/atlas.js b/backend/routes/atlas.js index ac73437..0417e6a 100644 --- a/backend/routes/atlas.js +++ b/backend/routes/atlas.js @@ -291,28 +291,35 @@ function createAtlasRouter() { if (result.status >= 200 && result.status < 300) { let allPlans = []; let activePlans = []; + let atlasRecognizesHost = false; try { const parsed = JSON.parse(result.body); if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) { - activePlans = Array.isArray(parsed.active) ? parsed.active : []; - const inactive = Array.isArray(parsed.inactive) ? parsed.inactive : []; - allPlans = [...activePlans, ...inactive]; + // Check for "not found" error responses that come back as 200 + if (parsed.error || parsed.message?.includes('not found')) { + atlasRecognizesHost = false; + } else { + atlasRecognizesHost = true; + activePlans = Array.isArray(parsed.active) ? parsed.active : []; + const inactive = Array.isArray(parsed.inactive) ? parsed.inactive : []; + allPlans = [...activePlans, ...inactive]; + } } else if (Array.isArray(parsed)) { + atlasRecognizesHost = true; allPlans = parsed; activePlans = parsed; } } catch (e) { allPlans = []; activePlans = []; + atlasRecognizesHost = false; } const planCount = activePlans.length; const hasActionPlan = planCount > 0; - // Atlas "knows" this host if: - // 1. It returned any plans (active or inactive), OR - // 2. The host belongs to a managed BU (these should always show the badge) - // Non-managed BU hosts with empty responses don't get a badge. - const atlasKnown = allPlans.length > 0 || isManagedHost; + // Atlas knows this host if it returned a valid structured response + // (not "not found" or error). This determines whether the badge renders. + const atlasKnown = atlasRecognizesHost; try { if (!hasActionPlan) {