Fix regex pattern matching for validate command#595
Closed
isaac-fletcher wants to merge 1 commit intofacebookincubator:mainfrom
Closed
Fix regex pattern matching for validate command#595isaac-fletcher wants to merge 1 commit intofacebookincubator:mainfrom
isaac-fletcher wants to merge 1 commit intofacebookincubator:mainfrom
Conversation
|
@isaac-fletcher has exported this pull request. If you are a Meta employee, you can view the originating Diff in D92402443. |
isaac-fletcher
added a commit
to isaac-fletcher/TTPForge
that referenced
this pull request
Feb 6, 2026
Summary:
The existing regex patterns for `templateVarPattern` and `stepVarsPattern` only matched simple template variable references like `{{.Args.x}}`. This caused the validate command to miss template variables used in more complex Go template expressions such as:
- Conditionals: `{{if .Args.x}}`
- Function calls: `{{printf "%s" .Args.x}}`
- Whitespace variations: `{{ .Args.x }}`
Updated the regex patterns to match `.Args.varname` and `.StepVars.varname` anywhere within their respective template delimiters (`{{ }}` and `{[{ }]}`), ensuring all template variable references are properly validated.
Reviewed By: ivnik
Differential Revision: D92402443
f7dbefe to
f85d221
Compare
isaac-fletcher
added a commit
to isaac-fletcher/TTPForge
that referenced
this pull request
Feb 6, 2026
Summary:
The existing regex patterns for `templateVarPattern` and `stepVarsPattern` only matched simple template variable references like `{{.Args.x}}`. This caused the validate command to miss template variables used in more complex Go template expressions such as:
- Conditionals: `{{if .Args.x}}`
- Function calls: `{{printf "%s" .Args.x}}`
- Whitespace variations: `{{ .Args.x }}`
Updated the regex patterns to match `.Args.varname` and `.StepVars.varname` anywhere within their respective template delimiters (`{{ }}` and `{[{ }]}`), ensuring all template variable references are properly validated.
Additionally, fixed false positive errors for StepVars that are defined in subttps. When a TTP references a subttp via the `ttp:` field, the subttp can export outputvars to the parent TTP. Since we cannot validate which variables the subttp produces without loading it, we now emit a warning instead of an error when a StepVar is not found locally but subttp steps exist. This allows valid TTPs like `subttps-and-variables.yaml` to pass validation while still alerting users to potentially undefined variables.
Reviewed By: ivnik
Differential Revision: D92402443
f85d221 to
e69507d
Compare
isaac-fletcher
added a commit
to isaac-fletcher/TTPForge
that referenced
this pull request
Feb 6, 2026
Summary:
The existing regex patterns for `templateVarPattern` and `stepVarsPattern` only matched simple template variable references like `{{.Args.x}}`. This caused the validate command to miss template variables used in more complex Go template expressions such as:
- Conditionals: `{{if .Args.x}}`
- Function calls: `{{printf "%s" .Args.x}}`
- Whitespace variations: `{{ .Args.x }}`
Updated the regex patterns to match `.Args.varname` and `.StepVars.varname` anywhere within their respective template delimiters (`{{ }}` and `{[{ }]}`), ensuring all template variable references are properly validated.
Additionally, fixed false positive errors for StepVars that are defined in subttps. When a TTP references a subttp via the `ttp:` field, the subttp can export outputvars to the parent TTP. Since we cannot validate which variables the subttp produces without loading it, we now emit a warning instead of an error when a StepVar is not found locally but subttp steps exist. This allows valid TTPs like `subttps-and-variables.yaml` to pass validation while still alerting users to potentially undefined variables.
Reviewed By: ivnik
Differential Revision: D92402443
e69507d to
976a423
Compare
isaac-fletcher
added a commit
to isaac-fletcher/TTPForge
that referenced
this pull request
Feb 6, 2026
Summary:
The existing regex patterns for `templateVarPattern` and `stepVarsPattern` only matched simple template variable references like `{{.Args.x}}`. This caused the validate command to miss template variables used in more complex Go template expressions such as:
- Conditionals: `{{if .Args.x}}`
- Function calls: `{{printf "%s" .Args.x}}`
- Whitespace variations: `{{ .Args.x }}`
Updated the regex patterns to match `.Args.varname` and `.StepVars.varname` anywhere within their respective template delimiters (`{{ }}` and `{[{ }]}`), ensuring all template variable references are properly validated.
Additionally, fixed false positive errors for StepVars that are defined in subttps. When a TTP references a subttp via the `ttp:` field, the subttp can export outputvars to the parent TTP. Since we cannot validate which variables the subttp produces without loading it, we now emit a warning instead of an error when a StepVar is not found locally but subttp steps exist. This allows valid TTPs like `subttps-and-variables.yaml` to pass validation while still alerting users to potentially undefined variables.
Reviewed By: ivnik
Differential Revision: D92402443
976a423 to
223615b
Compare
Summary:
The existing regex patterns for `templateVarPattern` and `stepVarsPattern` only matched simple template variable references like `{{.Args.x}}`. This caused the validate command to miss template variables used in more complex Go template expressions such as:
- Conditionals: `{{if .Args.x}}`
- Function calls: `{{printf "%s" .Args.x}}`
- Whitespace variations: `{{ .Args.x }}`
Updated the regex patterns to match `.Args.varname` and `.StepVars.varname` anywhere within their respective template delimiters (`{{ }}` and `{[{ }]}`), ensuring all template variable references are properly validated.
Additionally, fixed false positive errors for StepVars that are defined in subttps. When a TTP references a subttp via the `ttp:` field, the subttp can export outputvars to the parent TTP. Since we cannot validate which variables the subttp produces without loading it, we now emit a warning instead of an error when a StepVar is not found locally but subttp steps exist. This allows valid TTPs like `subttps-and-variables.yaml` to pass validation while still alerting users to potentially undefined variables.
Reviewed By: ivnik
Differential Revision: D92402443
223615b to
5a45e26
Compare
|
This pull request has been merged in 176c4a9. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The existing regex patterns for
templateVarPatternandstepVarsPatternonly matched simple template variable references like{{.Args.x}}. This caused the validate command to miss template variables used in more complex Go template expressions such as:{{if .Args.x}}{{printf "%s" .Args.x}}{{ .Args.x }}Updated the regex patterns to match
.Args.varnameand.StepVars.varnameanywhere within their respective template delimiters ({{ }}and{[{ }]}), ensuring all template variable references are properly validated.Differential Revision: D92402443