Skip to content

Fix YAML syntax error in workflow file#11277

Merged
sensei-hacker merged 1 commit intoiNavFlight:maintenance-9.xfrom
sensei-hacker:ci/pg-version-check-action
Jan 22, 2026
Merged

Fix YAML syntax error in workflow file#11277
sensei-hacker merged 1 commit intoiNavFlight:maintenance-9.xfrom
sensei-hacker:ci/pg-version-check-action

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 potential expression delimiter misinterpretation by GitHub Actions


Diagram Walkthrough

flowchart LR
  A["Template Literals<br/>with dollar-brace syntax"] -->|Replace with| B["String Concatenation<br/>with explicit newlines"]
  B -->|Result| C["YAML Parser<br/>Compatible Syntax"]
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 for output variable with
    single-quoted string
  • Converted multi-line template literal for commentBody to string
    concatenation with explicit newline characters
  • Maintained identical comment content while using compatible YAML
    syntax
  • Escaped single quotes in concatenated strings where necessary
+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 a7252d3 into iNavFlight:maintenance-9.x Jan 22, 2026
25 of 42 checks passed
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

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, move the complex JavaScript logic from the inline script in the YAML workflow into a separate .js file. This avoids YAML parsing issues and separates code from configuration. [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 }}';
      // ... 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' +
        // ... more concatenated strings ...
        '*This is an automated check...*';
      
      // ... 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 postCommentScript = require('./.github/scripts/post-comment.js');
      await postCommentScript({
        github,
        context,
        output: '${{ steps.pg_check.outputs.output }}'
      });

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

script: |
// Use the captured output from the previous step
const output = `${{ steps.pg_check.outputs.output }}`;
const output = '${{ steps.pg_check.outputs.output }}';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: To prevent potential syntax errors, pass the step output to the script via an environment variable instead of string interpolation. This requires adding an env block to the step and accessing it with process.env. [general, importance: 7]

Suggested change
const output = '${{ steps.pg_check.outputs.output }}';
const output = process.env.STEP_OUTPUT;

Comment on lines +76 to +92
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' +
'Modifying PG struct fields without incrementing the version can cause settings corruption when users flash new firmware. The `pgLoad()` function validates versions and will use defaults if there\'s a mismatch, preventing corruption.\n\n' +
'**When to increment the version:**\n' +
'- ✅ Adding/removing fields\n' +
'- ✅ Changing field types or sizes\n' +
'- ✅ Reordering fields\n' +
'- ✅ Adding/removing packing attributes\n' +
'- ❌ Only changing default values in `PG_RESET_TEMPLATE`\n' +
'- ❌ Only changing comments\n\n' +
'**Reference:**\n' +
'- [Parameter Group Documentation](../docs/development/parameter_groups/)\n' +
'- Example: [PR #11236](https://github.com/iNavFlight/inav/pull/11236) (field removal requiring version increment)\n\n' +
'---\n' +
'*This is an automated check. False positives are possible. If you believe the version increment is not needed, please explain in a comment.*';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Refactor the commentBody string concatenation into an array of strings, then use .join('\n') to construct the final message. This improves readability and maintainability. [general, importance: 6]

Suggested change
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' +
'Modifying PG struct fields without incrementing the version can cause settings corruption when users flash new firmware. The `pgLoad()` function validates versions and will use defaults if there\'s a mismatch, preventing corruption.\n\n' +
'**When to increment the version:**\n' +
'- ✅ Adding/removing fields\n' +
'- ✅ Changing field types or sizes\n' +
'- ✅ Reordering fields\n' +
'- ✅ Adding/removing packing attributes\n' +
'- ❌ Only changing default values in `PG_RESET_TEMPLATE`\n' +
'- ❌ Only changing comments\n\n' +
'**Reference:**\n' +
'- [Parameter Group Documentation](../docs/development/parameter_groups/)\n' +
'- Example: [PR #11236](https://github.com/iNavFlight/inav/pull/11236) (field removal requiring version increment)\n\n' +
'---\n' +
'*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',
'',
'The following parameter groups may need version increments:',
issuesContent,
'',
'**Why this matters:**',
'Modifying PG struct fields without incrementing the version can cause settings corruption when users flash new firmware. The `pgLoad()` function validates versions and will use defaults if there\'s a mismatch, preventing corruption.',
'',
'**When to increment the version:**',
'- ✅ Adding/removing fields',
'- ✅ Changing field types or sizes',
'- ✅ Reordering fields',
'- ✅ Adding/removing packing attributes',
'- ❌ Only changing default values in `PG_RESET_TEMPLATE`',
'- ❌ Only changing comments',
'',
'**Reference:**',
'- [Parameter Group Documentation](../docs/development/parameter_groups/)',
'- Example: [PR #11236](https://github.com/iNavFlight/inav/pull/11236)',
'',
'---',
'*This is an automated check. False positives are possible. If you believe the version increment is not needed, please explain in a comment.*'
].join('\n');

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