From eac00b3e3912cccff5da73394bc62dd8751bcf9d Mon Sep 17 00:00:00 2001 From: taylanbakircioglu Date: Mon, 26 Jan 2026 15:25:16 +0300 Subject: [PATCH] fix: consistent section header detection in listen extraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additional fix for listen block extraction: - Section boundary check now uses ([[:space:]]|$) pattern - Previously only checked [[:space:]], missing 'defaults' at end of line - Ensures listen extraction stops correctly at any section header Pattern consistency verified across all 4 locations: - Linux install mode: global, defaults, listen extraction ✓ - Linux daemon mode: global, defaults, listen extraction ✓ - macOS install mode: global, defaults, listen extraction ✓ - macOS daemon mode: global, defaults, listen extraction ✓ Edge cases tested: - Named defaults (defaults http): works correctly - Multiple listen blocks: all preserved - Tab characters: handled by [[:space:]] - User's actual config structure: produces clean merge No impact on other agent functions (self-upgrade, metrics, etc.) --- backend/utils/agent_scripts/linux_install.sh | 8 ++++++-- backend/utils/agent_scripts/macos_install.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/utils/agent_scripts/linux_install.sh b/backend/utils/agent_scripts/linux_install.sh index cb750b2..bdf657b 100644 --- a/backend/utils/agent_scripts/linux_install.sh +++ b/backend/utils/agent_scripts/linux_install.sh @@ -1743,7 +1743,9 @@ check_config_updates() { } in_listen { # Check if we hit another section (frontend, backend, listen, global, defaults) - if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) { + # CRITICAL FIX: Match keywords followed by whitespace OR end of line + # This handles "defaults" without trailing whitespace + if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) { # Print current listen block gsub(/\n[[:space:]]*$/, "", listen_content) print listen_content @@ -2925,7 +2927,9 @@ CONFIG_RESPONSE_EOF } in_listen { # Check if we hit another section (frontend, backend, listen, global, defaults) - if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) { + # CRITICAL FIX: Match keywords followed by whitespace OR end of line + # This handles "defaults" without trailing whitespace + if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) { # Print current listen block gsub(/\n[[:space:]]*$/, "", listen_content) print listen_content diff --git a/backend/utils/agent_scripts/macos_install.sh b/backend/utils/agent_scripts/macos_install.sh index c306dab..dfab08e 100644 --- a/backend/utils/agent_scripts/macos_install.sh +++ b/backend/utils/agent_scripts/macos_install.sh @@ -1689,7 +1689,9 @@ check_config_updates() { } in_listen { # Check if we hit another section (frontend, backend, listen, global, defaults) - if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) { + # CRITICAL FIX: Match keywords followed by whitespace OR end of line + # This handles "defaults" without trailing whitespace + if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) { # Print current listen block gsub(/\n[[:space:]]*$/, "", listen_content) print listen_content @@ -2873,7 +2875,9 @@ CONFIG_RESPONSE_EOF } in_listen { # Check if we hit another section (frontend, backend, listen, global, defaults) - if (/^(frontend|backend|listen|global|defaults)[[:space:]]/) { + # CRITICAL FIX: Match keywords followed by whitespace OR end of line + # This handles "defaults" without trailing whitespace + if (/^(frontend|backend|listen|global|defaults)([[:space:]]|$)/) { # Print current listen block gsub(/\n[[:space:]]*$/, "", listen_content) print listen_content