Skip to content

Prevent trailing commas inside expression funcs (hashFiles) from triggering workflow crash #368

@eugengi

Description

@eugengi

Describe the bug

🛈 I must admit that this may not be a bug and is subject to the project author's decision.

I've had my workflows crash several times due to having a trailing comma used in the hashFiles input. These can be added manually or through linters/formatters. In my case, it's a learned habit, for a few reasons (cleaner vcs diffs, editing, ...). This minor formatting detail raises a TemplateValidationErrors syntax error and crashes a running pipeline (workflow).

To Reproduce

Steps to reproduce the behavior:

  1. Create a workflow step containing an expression function with a trailing comma:
- name: Cache dependencies
  uses: actions/cache@v4
  with:
    path: ~/.cache/uv
    key: python-cache-${{ hashFiles('pyproject.toml', 'uv.lock', ) }}
  1. Trigger/run the workflow.
  2. Observe the syntax/parser initialization failure in the logs [error:: TemplateValidationErrors]

Expected Behavior

The expression syntax parsing logic can ignore the trailing comma when it precedes a closing parenthesis. ). This aligns better with modern config parser standards (imo) and also prevents minor syntax elements from breaking pipelines.

Screenshots

Image

Metadata

Package/Area

  • Expressions
  • Workflow Parser
  • Language Service
  • Language Server

Package Version
v1.x.y

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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