Skip to content

Report the Right Line in sha-pin When a Blank Line Precedes uses: #1966

Closed

Description

@ptr727

Finding

The USES pattern in .github/actions/repo-gate/repo_gate.py is ^\s*-?\s*uses:\s*(?P<ref>[^\s#]+) under re.MULTILINE. \s matches a newline, so where a uses: line follows a blank line the match can begin on the blank line, and m.start() points there. Every sha-pin message that computes its line from m.start() then reports one line too low.

A constructed workflow jobs:\n a:\n\n uses: .github/x\n reports line 3, while the uses: sits on line 4.

Suggested fix

Anchor the leading whitespace to the line, for example ^[ \t]*-?[ \t]*uses:, and add a case with a blank line before the uses: asserting the reported line number.

Found by a local strict review on the pull request for #1889, outside that change's scope.

Activity

  1. ptr727 commented on Sep 28, 2026

    @ptr727
    OwnerAuthor

    Fixed on the pull request for #1889, #1967, in 7f6ebb7 and 8d13c78, and it closes on promotion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions