MCPcopy Create free account
hub / github.com/github/gh-aw / validateExpressionSyntax

Function validateExpressionSyntax

pkg/workflow/expression_syntax_validation.go:86–113  ·  view source on GitHub ↗

validateExpressionSyntax validates the syntax of expressions within ${{ }}

(group string)

Source from the content-addressed store, hash-verified

84
85// validateExpressionSyntax validates the syntax of expressions within ${{ }}
86func validateExpressionSyntax(group string) error {
87 matches := expressionBracesPattern.FindAllStringSubmatch(group, -1)
88
89 expressionValidationLog.Printf("Found %d expression(s) to validate", len(matches))
90
91 for _, match := range matches {
92 if len(match) < 2 {
93 continue
94 }
95
96 exprContent := strings.TrimSpace(match[1])
97 if exprContent == "" {
98 return NewValidationError(
99 "expression",
100 "empty expression content",
101 "found empty expression '${{ }}' in: "+group,
102 "Provide a valid GitHub Actions expression inside '${{ }}'. Example: '${{ github.ref }}'",
103 )
104 }
105
106 // Check for common syntax errors
107 if err := validateExpressionContent(exprContent, group); err != nil {
108 return err
109 }
110 }
111
112 return nil
113}
114
115// validateExpressionContent validates the content inside ${{ }}
116func validateExpressionContent(expr string, fullGroup string) error {

Callers 1

Calls 3

NewValidationErrorFunction · 0.70
PrintfMethod · 0.45

Tested by

no test coverage detected