[Backend] Duplicate placeholder names in structured-log templates render unbound holes and collide in Seq (SonarQube S6677 x3) #635

Closed
opened 2026-07-17 04:50:13 +00:00 by spikerj · 1 comment
Owner

From the SonarQube triage loop (2026-07-17), verified by hand — real bugs, not noise:

  • SpikerSoft.EventHandlers.CodeExecution/Services/PythonInterpreterProbeHostedService.cs:61 — template uses {Minimum} twice with only one matching argument.
  • SpikerSoft.EventHandlers.ArtPipeProcessor/Services/ArtPipeStageOrchestrator.cs:430 and :469{Detected} twice with one argument.

Serilog binds holes to arguments positionally, so the final hole goes UNBOUND: the rendered message literally ends with {Minimum}/{Detected}, and the event property bag keeps a single value — Seq queries and dashboards see broken messages on exactly the diagnostics that matter (Python-version probe warnings, art_pipe safety-gate mislabel warnings).

Fix: reword each template to mention the value once (no argument changes, no behavior change beyond correct rendering), plus a source-guard test LogTemplatesHaveUniquePlaceholdersTests in SpikerSoft.Common.Tests (house pattern: PublishersUseTheTracedHelperTests) so the class of bug fails PRs directly — the sonar quality gate is deliberately non-blocking (#632), so it cannot be the enforcement point. Guard verified to fail on the pre-fix code (3 offenders) and pass after.

From the SonarQube triage loop (2026-07-17), verified by hand — real bugs, not noise: - `SpikerSoft.EventHandlers.CodeExecution/Services/PythonInterpreterProbeHostedService.cs:61` — template uses `{Minimum}` twice with only one matching argument. - `SpikerSoft.EventHandlers.ArtPipeProcessor/Services/ArtPipeStageOrchestrator.cs:430` and `:469` — `{Detected}` twice with one argument. Serilog binds holes to arguments positionally, so the final hole goes UNBOUND: the rendered message literally ends with `{Minimum}`/`{Detected}`, and the event property bag keeps a single value — Seq queries and dashboards see broken messages on exactly the diagnostics that matter (Python-version probe warnings, art_pipe safety-gate mislabel warnings). Fix: reword each template to mention the value once (no argument changes, no behavior change beyond correct rendering), plus a source-guard test `LogTemplatesHaveUniquePlaceholdersTests` in SpikerSoft.Common.Tests (house pattern: PublishersUseTheTracedHelperTests) so the class of bug fails PRs directly — the sonar quality gate is deliberately non-blocking (#632), so it cannot be the enforcement point. Guard verified to fail on the pre-fix code (3 offenders) and pass after.
Author
Owner

Resolved in spikersoft-backend PR #342 (merged to master). The three S6677 duplicate-placeholder templates are reworded (unbound holes no longer render literally in the Python-probe and art_pipe safety-gate warnings), and the new LogTemplatesHaveUniquePlaceholdersTests source guard fails any PR that reintroduces the pattern — verified failing on pre-fix code (exactly the 3 sites) and passing after, no other offenders repo-wide. Note: the red 'SonarQube Scan' on the merge commit was the pre-existing #632 scan-container condition (LLama natives), unrelated to this change; the unit-test verification for this PR ran locally and green. Closing.

Resolved in spikersoft-backend PR #342 (merged to master). The three S6677 duplicate-placeholder templates are reworded (unbound holes no longer render literally in the Python-probe and art_pipe safety-gate warnings), and the new LogTemplatesHaveUniquePlaceholdersTests source guard fails any PR that reintroduces the pattern — verified failing on pre-fix code (exactly the 3 sites) and passing after, no other offenders repo-wide. Note: the red 'SonarQube Scan' on the merge commit was the pre-existing #632 scan-container condition (LLama natives), unrelated to this change; the unit-test verification for this PR ran locally and green. Closing.
Sign in to join this conversation.