Skip to content

Fix regex pattern matching for validate command#595

Closed
isaac-fletcher wants to merge 1 commit intofacebookincubator:mainfrom
isaac-fletcher:export-D92402443
Closed

Fix regex pattern matching for validate command#595
isaac-fletcher wants to merge 1 commit intofacebookincubator:mainfrom
isaac-fletcher:export-D92402443

Conversation

@isaac-fletcher
Copy link
Contributor

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.

Differential Revision: D92402443

@meta-codesync
Copy link

meta-codesync bot commented Feb 5, 2026

@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
@isaac-fletcher isaac-fletcher force-pushed the export-D92402443 branch 2 times, most recently from f7dbefe to f85d221 Compare February 6, 2026 19:15
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
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
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
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
@meta-codesync
Copy link

meta-codesync bot commented Feb 6, 2026

This pull request has been merged in 176c4a9.

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.

2 participants