Skip to content

Fix: correct error handling for non-string keys in YAML validation #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kfess
Copy link

@kfess kfess commented May 12, 2025

Description
This PR fixes the incorrect error messages that appear when YAML files contain non-string keys (numbers, null, boolean values) in the GitHub Actions VSCode extension.
I think the issue is caused by the YAML parser assuming all keys are strings without proper type conversion.

Changes Made

  • Modified the YAML parser to properly convert all scalar values to strings before processing
  • Replaced the type assertion as string with explicit string conversion using String()
  • Added special handling for null values to convert them to empty strings, matching the GitHub Actions runner behavior
  • Fixed JavaScript errors like i.indexOf is not a function that occurred with numeric keys
  • Ensured boolean keys (true/false) are properly stringified

Fix #185

@Copilot Copilot AI review requested due to automatic review settings May 12, 2025 13:45
@kfess kfess requested a review from a team as a code owner May 12, 2025 13:45
Copy link

@Copilot 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 fixes error handling during YAML validation by ensuring that non-string keys (null, boolean, numeric) are properly converted to strings.

  • Replaces type assertion with explicit string conversion using String(), with special handling for null keys.
  • Addresses JavaScript errors like "i.indexOf is not a function" by converting all scalar values to strings.
Comments suppressed due to low confidence (1)

workflow-parser/src/workflows/yaml-object-reader.ts:80

  • Verify that using String() conversion properly handles numeric and boolean values as expected by the GitHub Actions runner behavior, and consider adding tests to cover these scenarios.
const key = scalarKey.value === null ? "" : String(scalarKey.value);

@kfess kfess changed the title fix: correct error handling for non-string keys in YAML validation Fix: correct error handling for non-string keys in YAML validation May 12, 2025
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.

Incorrect error messages for non-string keys (number/null/boolean) in YAML validation
1 participant