Skip to content

Conversation

@sensei-hacker
Copy link
Member

@sensei-hacker sensei-hacker commented Jan 22, 2026

User description

Replace JavaScript template literals with string concatenation to avoid YAML parser confusion with template literal interpolation syntax. GitHub Actions YAML parser can misinterpret template literal dollar-brace syntax as expression delimiters.


PR Type

Bug fix


Description

  • Replace template literals with string concatenation in GitHub Actions workflow

  • Avoid YAML parser confusion with template literal dollar-brace syntax

  • Fix expression delimiter misinterpretation in workflow script


Diagram Walkthrough

flowchart LR
  A["Template Literals with Dollar-Brace"] -->|Replace with| B["String Concatenation"]
  B -->|Prevents| C["YAML Parser Confusion"]
  C -->|Ensures| D["Correct Workflow Execution"]
Loading

File Walkthrough

Relevant files
Bug fix
pg-version-check.yml
Replace template literals with string concatenation           

.github/workflows/pg-version-check.yml

  • Replaced JavaScript template literal with single-quoted string for
    output variable
  • Converted multi-line template literal to string concatenation for
    commentBody variable
  • Escaped single quotes and backticks in concatenated strings
  • Maintained identical comment content while fixing YAML parsing issues
+18/-24 

Replace JavaScript template literals with string concatenation to avoid
YAML parser confusion with template literal interpolation syntax.
GitHub Actions YAML parser can misinterpret template literal dollar-brace
syntax as expression delimiters.
@sensei-hacker sensei-hacker merged commit da2a35c into iNavFlight:master Jan 22, 2026
21 checks passed
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@github-actions
Copy link

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

High-level Suggestion

To improve readability and maintainability, extract the inline JavaScript from the YAML workflow into a separate .js file. This avoids syntax conflicts and makes the script easier to manage. [High-level, importance: 8]

Solution Walkthrough:

Before:

# in .github/workflows/pg-version-check.yml
- name: Post comment if issues found
  if: steps.pg_check.outputs.exit_code == '1'
  uses: actions/github-script@v7
  with:
    script: |
      const output = '${{ steps.pg_check.outputs.output }}';
      let issuesContent = '...';
      // ... logic to parse issues ...
      const commentBody = '## ⚠️ Parameter Group Version Check\n\n' +
        'The following parameter groups may need version increments:\n\n' +
        issuesContent + '\n\n' +
        '**Why this matters:**\n' +
        '...';
      
      // ... logic to post comment ...

After:

# in .github/workflows/pg-version-check.yml
- name: Post comment if issues found
  if: steps.pg_check.outputs.exit_code == '1'
  uses: actions/github-script@v7
  with:
    script: |
      const script = require('./.github/scripts/post-comment.js');
      await script({
        github, 
        context, 
        output: `${{ steps.pg_check.outputs.output }}`
      });

# in a new file .github/scripts/post-comment.js
module.exports = async ({ github, context, output }) => {
  let issuesContent = '...';
  // ... logic to parse issues from `output` ...
  const commentBody = `## ⚠️ Parameter Group Version Check

  The following parameter groups may need version increments:

  ${issuesContent}

  **Why this matters:**
  ...`;
  // ... logic to post comment ...
};

*This is an automated check. False positives are possible. If you believe the version increment is not needed, please explain in a comment.*`;
const commentBody = '## ⚠️ Parameter Group Version Check\n\n' +
'The following parameter groups may need version increments:\n\n' +
issuesContent + '\n\n' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Wrap the issuesContent variable in a fenced code block to prevent unintended markdown formatting in the final comment. [general, importance: 6]

Suggested change
issuesContent + '\n\n' +
'```\n' + issuesContent + '\n```\n\n' +

Comment on lines +52 to 53
const output = '${{ steps.pg_check.outputs.output }}';
let issuesContent = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Add a size/emptiness guard for output (GitHub comments have limits and step outputs can be empty/huge) and truncate or fall back before parsing/using it. [Learned best practice, importance: 6]

Suggested change
const output = '${{ steps.pg_check.outputs.output }}';
let issuesContent = '';
const rawOutput = '${{ steps.pg_check.outputs.output }}';
const MAX_OUTPUT_CHARS = 60000; // keep below GitHub comment limits
const output = (rawOutput ?? '').toString().slice(0, MAX_OUTPUT_CHARS);
let issuesContent = output.length ? '' : '*No output captured from pg_check step*';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant