Skip to content

[Code Quality] Introduce named Frontmatter type with typed accessors to replace map[string]any parameter #51031

Description

@github-actions

Description

The frontmatter map[string]any parameter signature is repeated 290 times across 128 files, including UpdateWorkflowFrontmatter, the ~40 codemods in pkg/cli, and the Compiler.extract*FromOn helpers in pkg/workflow/pkg/parser. Each call site hand-rolls .(string)/.([]any) type assertions against the untyped map, which is error-prone and hard to discover/refactor safely.

Suggested Changes

  • Define a named type Frontmatter map[string]any (or a thin wrapper struct) with typed accessor methods, e.g. GetString(key string) (string, bool), GetStringSlice(key string) ([]string, bool), GetMap(key string) (Frontmatter, bool).
  • Migrate UpdateWorkflowFrontmatter and the Compiler.extract*FromOn helpers to use the new type first (highest-traffic call sites).
  • Progressively migrate the ~40 pkg/cli codemods to use the typed accessors instead of raw assertions.
  • This is additive (the underlying type is still map[string]any), so it is a low-risk rename plus method-add rather than a breaking change.

Files Affected

  • All files calling UpdateWorkflowFrontmatter and Compiler.extract*FromOn (128 files total per source analysis)
  • Suggested new file: pkg/parser/frontmatter_type.go (or similar) for the type definition and accessors

Success Criteria

  • Frontmatter named type exists with typed accessor methods and unit tests
  • UpdateWorkflowFrontmatter and Compiler.extract*FromOn helpers migrated to use it
  • No behavior change; all existing tests pass

Source

Extracted from Typist - Go Type Consistency Analysis #50840

Priority

High impact, moderate effort (4-6h per source analysis) - touches many files but additive/low-risk

🔍 Task mining by Discussion Task Miner - Code Quality Improvement Agent · auto · 47.5 AIC · ⌖ 3.92 AIC · ⊞ 10.2K ·

  • expires on Aug 7, 2026, 11:12 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions