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) {