Skip to content

fix: guard null execSync return in benchmark exec helper#1772

Merged
Mossaka merged 1 commit intomainfrom
fix/benchmark-exec-null-trim
Apr 7, 2026
Merged

fix: guard null execSync return in benchmark exec helper#1772
Mossaka merged 1 commit intomainfrom
fix/benchmark-exec-null-trim

Conversation

@Mossaka
Copy link
Copy Markdown
Collaborator

@Mossaka Mossaka commented Apr 7, 2026

Summary

  • Guard against null return from execSync when called with { stdio: "ignore" } in the benchmark script's exec() helper. Without this, .trim() crashes with TypeError: Cannot read properties of null (reading 'trim'), breaking the entire performance-monitor workflow on the first benchmark.
  • Improve JSON validation in performance-monitor.yml to reject empty files (the previous jq empty check silently passed on empty input).

Details

When execSync is called with { stdio: "ignore" }, it returns null instead of a string. The exec() helper at line 58 of benchmark-performance.ts calls .trim() on the return value unconditionally, causing a crash. This affects benchmarkNetworkCreation() (line 311) and several other callers that pass { stdio: "ignore" }.

The fix uses nullish coalescing (?? "") to default to an empty string before calling .trim().

Additionally, the Validate benchmark JSON step in the workflow used jq empty which succeeds on empty files. Added a [ ! -s ... ] check to catch this case.

Discovered during end-to-end validation of the benchmark system.

Test plan

  • npm run build succeeds
  • npm test passes (1341 tests)
  • CI checks pass

🤖 Generated with Claude Code

When exec() is called with { stdio: "ignore" }, execSync returns null
instead of a string. Calling .trim() on null crashes with TypeError,
breaking the entire benchmark workflow on the first test.

Also improve JSON validation in performance-monitor.yml to catch empty
files, since `jq empty` passes on empty input.

Discovered during end-to-end validation of the benchmark system.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 7, 2026 23:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 86.14% 86.23% 📈 +0.09%
Statements 86.02% 86.11% 📈 +0.09%
Functions 87.45% 87.45% ➡️ +0.00%
Branches 78.81% 78.86% 📈 +0.05%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 86.3% → 86.7% (+0.37%) 85.9% → 86.2% (+0.36%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@Mossaka Mossaka added the bug Something isn't working label Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the performance benchmark tooling used by the Performance Monitor workflow by preventing a runtime crash in the benchmark script when execSync is invoked with stdio: "ignore", and by making the workflow’s benchmark JSON validation reject empty output files.

Changes:

  • Guard execSync(...) results in the benchmark exec() helper to avoid calling .trim() on null when stdio discards output.
  • Update the Performance Monitor workflow’s JSON validation to fail early when benchmark-results.json is empty.
Show a summary per file
File Description
scripts/ci/benchmark-performance.ts Prevents benchmark execution from crashing when execSync returns null under ignored stdio.
.github/workflows/performance-monitor.yml Strengthens benchmark result validation by rejecting empty result files before running jq.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

.github/workflows/performance-monitor.yml:75

  • The jq empty validation (even with the -s size check) will still succeed if benchmark-results.json contains only whitespace/newlines (non-zero size but no JSON values). To robustly fail on empty/whitespace input, consider switching to jq -e . benchmark-results.json >/dev/null (or a stricter filter that asserts the expected object shape) and relying on its exit code, optionally keeping a separate -f check for a clearer "missing file" error message.
          if [ ! -s benchmark-results.json ]; then
            echo "ERROR: benchmark-results.json is empty"
            exit 1
          fi
          if ! jq empty benchmark-results.json 2>/dev/null; then
            echo "ERROR: benchmark-results.json is not valid JSON"
            cat benchmark-results.json
            exit 1
          fi
  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Smoke Test Results — PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🔬 Smoke Test Results — PR #1772

Test Result
GitHub MCP connectivity ✅ PASS
GitHub.com HTTP connectivity ⚠️ N/A (template vars unresolved)
File write/read ⚠️ N/A (template vars unresolved)

PR: fix: guard null execSync return in benchmark exec helper
Author: @Mossaka · No assignees

Overall: ⚠️ INCONCLUSIVE — Pre-step outputs were not injected; MCP is functional but HTTP/file tests could not be verified.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING (host.docker.internal:6379) PONG
PostgreSQL ready (host.docker.internal:5432) ✅ accepting connections
PostgreSQL SELECT 1 (smoketest DB) ✅ returns 1

All checks passed. (redis-cli was unavailable; Redis was verified via raw TCP.)

🔌 Service connectivity validated by Smoke Services

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🔮 The oracle has read the runes of this smoke test.
PR: fix: measure memory while containers are running, not after teardown
PR: fix: separate stderr from stdout in benchmark to prevent invalid JSON
GitHub MCP ✅ | safeinputs-gh CLI ❌
Playwright ❌ | Tavily ❌
File write ✅ | Bash cat ✅
Discussion interaction ❌ | Build AWF ✅
Overall: FAIL

🔮 The oracle has spoken through Smoke Codex

@Mossaka Mossaka merged commit df63435 into main Apr 7, 2026
61 of 63 checks passed
@Mossaka Mossaka deleted the fix/benchmark-exec-null-trim branch April 7, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants