Skip to content

fix: remove normalizeNodeEval that breaks multiline node -e scripts#361

Closed
buger wants to merge 2 commits intomainfrom
fix/remove-node-eval-newline-escape
Closed

fix: remove normalizeNodeEval that breaks multiline node -e scripts#361
buger wants to merge 2 commits intomainfrom
fix/remove-node-eval-newline-escape

Conversation

@buger
Copy link
Contributor

@buger buger commented Feb 15, 2026

Summary

  • Removes the normalizeNodeEval function from command-check-provider.ts that incorrectly escaped newlines in node -e script arguments
  • This was breaking multiline scripts loaded from YAML exec blocks (e.g. slack-send-dm workflow) by replacing real newlines with literal \n sequences, causing SyntaxError: Invalid or unexpected token in Node.js
  • Commands are executed via child_process.exec() which passes them through /bin/sh -c, so multiline content inside quoted arguments works correctly without any normalization

Test plan

  • All 51 unit/integration tests pass
  • Verified fix with live Oel slack-send-dm workflow — script executes correctly with proper multiline rendering
  • npm run build succeeds

🤖 Generated with Claude Code

The normalizeNodeEval function replaced real newlines with literal \n
in node -e script arguments. This broke multiline scripts loaded from
YAML exec blocks (e.g. slack-send-dm workflow) because Node.js received
the entire script as a single line with literal \n sequences instead of
actual newlines, causing SyntaxError: Invalid or unexpected token.

Commands are executed via child_process.exec() which passes them through
/bin/sh -c, so multiline content inside quoted arguments is preserved
correctly by the shell. The normalization was unnecessary and harmful.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@probelabs
Copy link
Contributor

probelabs bot commented Feb 15, 2026

PR Overview: Remove normalizeNodeEval Breaking Multiline Node Scripts

Summary

This PR removes the normalizeNodeEval function from command-check-provider.ts that was incorrectly escaping newlines in node -e script arguments. The function was converting real newlines into literal sequences, causing SyntaxError: Invalid or unexpected token errors in Node.js when executing multiline scripts loaded from YAML exec blocks.

Files Changed

src/providers/command-check-provider.ts (-21 lines, +4 lines)

  • Removed the normalizeNodeEval function (lines 286-303)
  • Simplified command execution to use renderedCommand directly without normalization
  • Added explanatory comment about shell behavior with multiline arguments

Architecture & Impact Assessment

What This PR Accomplishes

The fix addresses a critical bug where multiline JavaScript code in YAML exec blocks (e.g., in the slack-send-dm workflow) would fail with syntax errors. The root cause was an overzealous normalization function that escaped newlines inside quoted arguments for node -e invocations.

Key Technical Changes

  1. Removed normalizeNodeEval function: This function used a regex pattern to detect node -e or node --eval invocations and escape newlines within the quoted code argument.

  2. Simplified command execution: The safeCommand variable now directly uses renderedCommand without any transformation.

  3. Added documentation: Comments explain that child_process.exec() passes commands through /bin/sh -c, which naturally preserves newlines inside quoted arguments.

Affected System Components

graph TD
    A[YAML exec block] --> B[Liquid Template Rendering]
    B --> C[renderedCommand]
    C --> D[commandExecutor.execute]
    D --> E[/bin/sh -c]
    E --> F["node -e 'multiline script'"]
    
    style F fill:#90EE90
    
    G[Removed: normalizeNodeEval] -.-> H["newline to 
 escape"]
    H -.-> I[SyntaxError in Node.js]
    
    style G fill:#FFB6C1
    style H fill:#FFB6C1
    style I fill:#FFB6C1
Loading

Impact Scope:

  • Primary: Command execution for node -e scripts with multiline content
  • Secondary: Any workflow using YAML exec blocks with multiline JavaScript (e.g., slack-send-dm)
  • No Impact: Single-line node -e scripts or other shell commands

Why This Works

Commands are executed via child_process.exec(), which passes them through /bin/sh -c. The shell correctly preserves newlines inside single or double-quoted arguments, making the normalization unnecessary and harmful.

Scope Discovery & Context Expansion

Related Files to Review

Based on the codebase structure, these areas may be affected or related:

  1. Workflow definitions using node -e with multiline scripts:

    • defaults/workflow-builder.yaml
    • Any custom workflows with exec blocks containing multiline JavaScript
  2. Test files for command execution:

    • tests/**/*command*.test.ts
    • Integration tests for the slack-send-dm workflow
  3. Related utilities:

    • src/utils/command-executor.ts (handles the actual child_process.exec call)

Potential Edge Cases

  • Scripts with intentional escape sequences (should now work correctly)
  • Cross-platform compatibility (Windows vs Unix shell behavior)
  • Mixed quoting styles (single vs double quotes in node -e)

Testing

The PR author confirmed:

  • ✅ All 51 unit/integration tests pass
  • ✅ Live testing with slack-send-dm workflow successful
  • ✅ Build succeeds (npm run build)

Reviewer Focus Areas

  1. Verify the shell behavior assumption: Confirm that /bin/sh -c on all target platforms preserves newlines in quoted arguments
  2. Check for similar patterns: Search for other places where command normalization might be occurring
  3. Test coverage: Ensure tests cover multiline node -e scripts specifically

Labels

  • Type: bug (fixes a breaking bug in multiline script execution)
  • Review Effort: 2 (small, focused change with clear impact)
Metadata
  • Review Effort: 2 / 5
  • Primary Label: bug

Powered by Visor from Probelabs

Last updated: 2026-02-15T16:29:10.759Z | Triggered by: pr_opened | Commit: a359ffa

💡 TIP: You can chat with Visor using /visor ask <your question>

@probelabs
Copy link
Contributor

probelabs bot commented Feb 15, 2026

✅ Security Check Passed

No security issues found – changes LGTM.

✅ Architecture Check Passed

No architecture issues found – changes LGTM.

✅ Performance Check Passed

No performance issues found – changes LGTM.

✅ Quality Check Passed

No quality issues found – changes LGTM.


Powered by Visor from Probelabs

Last updated: 2026-02-15T16:29:13.298Z | Triggered by: pr_opened | Commit: a359ffa

💡 TIP: You can chat with Visor using /visor ask <your question>

@buger buger closed this Feb 15, 2026
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.

1 participant