Skip to content

[plan] Split template_injection_validation.go by responsibility #26438

@github-actions

Description

@github-actions

Context

From discussion #26431 (Repository Quality Improvement Report — Validator Complexity Compliance).

pkg/workflow/template_injection_validation.go is 384 lines (28% over the 300-line hard limit in AGENTS.md). It contains 8 functions with 3 distinct responsibilities: detection, extraction utilities, and error formatting.

Objective

Extract utility and formatting helpers into a separate file, keeping core validation logic in the original file.

Steps

  1. Create pkg/workflow/template_injection_utils.go (same workflow package) with these utility/helper functions:
    • extractRunBlocks
    • removeHeredocContent
    • extractRunSnippet
    • detectExpressionContext
    • formatTemplateInjectionError
  2. Keep core validation entry points in template_injection_validation.go:
    • hasUnsafeExpressionInRunContent
    • validateNoTemplateInjection
    • validateNoTemplateInjectionFromParsed
  3. Verify template_injection_validation.go is under 250 lines
  4. Run make fmt && make lint && go test -run ".*TemplateInjection.*|.*templateInjection.*" ./pkg/workflow/

Acceptance Criteria

  • pkg/workflow/template_injection_validation.go retains the 3 core validation functions, under 250 lines
  • New file pkg/workflow/template_injection_utils.go created with the 5 utility functions listed above
  • No behaviour changes — pure file split within the workflow package
  • make fmt and make lint pass
  • All existing tests pass (make test-unit)

Generated by Plan Command for issue #discussion #26431 · ● 150.7K ·

  • expires on Apr 17, 2026, 1:25 PM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions