Skip to content

fix(agent): strip inline comments in env file parsing (#883) - #884

Merged
gnacho merged 1 commit into
mainfrom
fix/883-env-inline-comments
Sep 27, 2026
Merged

gnacho merged 1 commit into
mainfrom
fix/883-env-inline-comments

Conversation

@gnacho

@gnacho gnacho commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Qué

loadEnvFile solo ignoraba líneas de comentario completas; un comentario inline tras el valor (KEY=0 # nota) formaba parte del valor. En concreto NETPULSE_SCAN_INTERVAL=0 # ... no coincidía con el "0" exacto y caía en el warning "inválido, usando 30m" en vez de desactivar los scans.

Fix

Recortar el valor en el primer # antes de quitar comillas/espacios. Los valores que genera el server (URL, token, FP SPKI) nunca contienen #, así que es seguro.

Reportado por @crowedavid en #851 (comentario).

Tests

  • Nuevo TestLoadConfigInlineComments: SCAN_INTERVAL=0 con comentario inline aplica ScanDisabled; comentarios tras duración y tras valor entrecomillado se recortan.
  • go vet ./... && go test ./... del agente: todo ok.
  • Bump agent/VERSION 3.0.2 -> 3.0.3 (puerta CI).

Closes #883

loadEnvFile only skipped full-comment lines, so a line like
NETPULSE_SCAN_INTERVAL=0     # comment yielded the literal value
"0     # comment", missed the exact "0" match and fell back to the
30m default. Truncate values at the first " #" before trimming quotes;
server-generated values (URL, token, SPKI FP) never contain " #".
@gnacho
gnacho merged commit 96abc8f into main Sep 27, 2026
2 checks passed
@gnacho
gnacho deleted the fix/883-env-inline-comments branch September 27, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent env parser breaks on inline comments; NETPULSE_SCAN_INTERVAL=0 not honored

1 participant