Skip to content

Conversation

@ericsciple
Copy link
Collaborator

@ericsciple ericsciple commented Jan 7, 2026

Validates format() function calls for:

  • Invalid syntax (missing closing brace, empty placeholder, non-numeric placeholder)
  • Argument count mismatch (placeholder references arg that doesn't exist)

I added this validation in the consumer for now (languageservice), instead of directly in expression parsing. This matches the current server behavior. Otherwise we need to reconcile xlang test differences. Eventually this validation should be added on the server as well during parse time, at which point we can move the validation here to expression parsing as well. The alternative approach was explored here.

Validates format() function calls for:
- Invalid syntax (missing closing brace, empty placeholder, non-numeric placeholder)
- Argument count mismatch (placeholder references arg that doesn't exist)

Port of Go's format_validator.go from actions-workflow-parser.
@ericsciple ericsciple marked this pull request as ready for review January 7, 2026 22:23
@ericsciple ericsciple requested a review from a team as a code owner January 7, 2026 22:23
Copilot AI review requested due to automatic review settings January 7, 2026 22:23
Copy link
Contributor

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 adds validation for format() function calls in GitHub Actions workflows to catch invalid format string syntax and argument count mismatches at the language service level.

Key changes:

  • Implements format string parsing logic to validate placeholder syntax (numeric indices, escaped braces)
  • Validates that placeholder indices don't exceed the number of provided arguments
  • Integrates validation into the existing expression validation pipeline

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
languageservice/src/validate-format-string.ts New module implementing format string validation logic ported from Go implementation, including AST traversal to find all format() calls
languageservice/src/validate.ts Integrates format string validation into the expression validation flow and generates appropriate error diagnostics
languageservice/src/validate.format-string.test.ts Comprehensive test suite covering unit tests for format string parsing and integration tests for workflow validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ericsciple ericsciple merged commit 54404aa into main Jan 8, 2026
13 checks passed
@ericsciple ericsciple deleted the users/ericsciple/26-01-format branch January 8, 2026 15:25
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.

3 participants