From 4f7b5b826a4e8f9390fe0a615e0d0d0d22c04804 Mon Sep 17 00:00:00 2001 From: Mikhail Chusavitin Date: Thu, 21 May 2026 14:21:13 +0300 Subject: [PATCH] fix(inspur): fix PSU section regex when PCIE section precedes Network MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PSU regex used "RESTful Network" as its end anchor, but in standard Inspur component.log layout the PCIE Device section sits between PSU and Network Adapter. The lazy [\s\S]*? captured across the PCIE error block, producing invalid JSON and silently dropping all PSU data. Changed anchor to RESTful (?:PCIE|Network) — matches whichever section immediately follows PSU in a given archive. Co-Authored-By: Claude Sonnet 4.6 --- internal/parser/vendors/inspur/component.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/parser/vendors/inspur/component.go b/internal/parser/vendors/inspur/component.go index 00397e6..9c7bf84 100644 --- a/internal/parser/vendors/inspur/component.go +++ b/internal/parser/vendors/inspur/component.go @@ -250,7 +250,7 @@ type PSURESTInfo struct { func parsePSUInfo(text string, hw *models.HardwareConfig) { // Find RESTful PSU info section - re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful Network`) + re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful (?:PCIE|Network)`) match := re.FindStringSubmatch(text) if match == nil { return @@ -880,7 +880,7 @@ func parseDiskBackplaneSensors(text string) []models.SensorReading { } func parsePSUSummarySensors(text string) []models.SensorReading { - re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful Network`) + re := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful (?:PCIE|Network)`) match := re.FindStringSubmatch(text) if match == nil { return nil @@ -1028,7 +1028,7 @@ func extractComponentFirmware(text string, hw *models.HardwareConfig) { // Skip extracting from component.log to avoid duplicates // Extract PSU firmware from RESTful PSU info - rePSU := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful Network`) + rePSU := regexp.MustCompile(`RESTful PSU info:\s*(\{[\s\S]*?\})\s*RESTful (?:PCIE|Network)`) if match := rePSU.FindStringSubmatch(text); match != nil { jsonStr := strings.ReplaceAll(match[1], "\n", "") var psuInfo PSURESTInfo