Skip to content

Conversation

@vilsonrodrigues
Copy link
Contributor

Summary

This PR completely fixes all YAML syntax errors in the merge-bot workflow by replacing problematic template literals with array-based string construction.

Problem

After PR #21 was merged, the workflow still has multiple YAML parsing errors caused by template literals with backticks inside YAML string literals. GitHub Actions fails to parse the workflow file at multiple locations:

  • Line 420-424: Fork PR message with code block
  • Line 613: Success message with inline backticks
  • Line 635-645: Failure message with code block

Error pattern:

yaml.scanner.ScannerError: while scanning a simple key
could not find expected ':'

Root Cause

YAML parser struggles with:

  • Template literals containing escaped backticks: \``bash`
  • Multiline strings with complex interpolations
  • Nested backticks in template literals inside YAML script: blocks

Solution

Replace all problematic template literals with array-based string construction:

Before (❌ Causes YAML errors):

body: `Message here
\`\`\`bash
git fetch upstream ${pr.base.ref}
\`\`\`
More text`

After (✅ Clean and valid):

const message = [
  'Message here',
  '```bash',
  `git fetch upstream ${baseBranch}`,
  '```',
  'More text'
].join('\n');

body: message

Changes Made

  1. Fork PR message (lines 412-425): Array-based construction
  2. Success message (line 607): Extract to variable before use
  3. Failure message (lines 631-643): Array-based construction

Validation

Python YAML parser: Validates successfully
Node.js syntax check: JavaScript is valid
act (GitHub Actions local runner): Workflow parses correctly

All three validation methods pass!

Testing

After merge, test with PR #20:

  1. Comment /update on PR docs: enhance module docstring (TEST PR for /update command) #20
  2. Verify the bot can now run successfully
  3. Check that messages format correctly with code blocks

Related

🤖 Generated with Claude Code

vilsonrodrigues and others added 3 commits December 1, 2025 17:18
Fix template literal interpolation issue by extracting pr.base.ref to
a local variable before using it in the comment body. This prevents
YAML parsing errors with the GitHub Actions workflow.

The issue occurs when GitHub Actions tries to parse the workflow file
and encounters ${pr.base.ref} inside a JavaScript template literal,
which can be confused with GitHub Actions variable interpolation syntax.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Replace all problematic template literals with backticks inside YAML with
array-based string construction using .join('\n'). This prevents YAML parser
errors when GitHub Actions tries to validate the workflow file.

Changes:
- Fork PR message: Use array of strings instead of multiline template literal
- Success message: Extract to variable to avoid inline template complexity
- Failure message: Use array of strings for code block formatting

This approach avoids:
- Escaped backticks in YAML (\`\`\`)
- Complex template literals inside YAML string literals
- YAML scanner errors with 'could not find expected :'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vilsonrodrigues
Copy link
Contributor Author

/merge

@vilsonrodrigues vilsonrodrigues merged commit 9636d98 into msgflux:main Dec 1, 2025
7 checks passed
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