Skip to content

gh run view --log throws regex parsing error when job name contains ++ #3736

@adityasharad

Description

@adityasharad

Describe the bug

gh run view --log throws a regex parsing error if the Actions job name contains a ++ character sequence.
It appears to be interpreted as a regex, without escaping.

Version: gh version 1.10.3 (2021-05-21)
OS: MacOS Catalina 10.15.7

Steps to reproduce the behavior

  1. Create an Actions workflow with a job whose name contains ++, e.g. Pre-check: C++ tests
  2. gh run view --log --job <job-id>
  3. Observe the error below:
    panic: regexp: Compile(`Pre-check: C++ tests\/1_.*\.txt`): error parsing regexp: invalid nested repetition operator: `++`
    
    goroutine 1 [running]:
    regexp.MustCompile(0xc000947f80, 0x2c, 0xc0004f6fb0)
            regexp/regexp.go:311 +0x157
    github.com/cli/cli/pkg/cmd/run/view.logFilenameRegexp(0xa04b531a, 0xc0008cc0e0, 0x9, 0xc0008cc0b8, 0x7, 0xc0009473b0, 0x21, 0xc000373180, 0xc, 0xd, ...)
            github.com/cli/cli/pkg/cmd/run/view/view.go:466 +0xd6
    github.com/cli/cli/pkg/cmd/run/view.attachRunLog(0xc000a1b180, 0xc0004f7700, 0x1, 0x1)
            github.com/cli/cli/pkg/cmd/run/view/view.go:486 +0x2b8
    github.com/cli/cli/pkg/cmd/run/view.runView(0xc0008ffab0, 0x0, 0x0)
            github.com/cli/cli/pkg/cmd/run/view/view.go:271 +0x2377
    github.com/cli/cli/pkg/cmd/run/view.NewCmdView.func1(0xc00092a000, 0xc0009662d0, 0x0, 0x5, 0x0, 0x0)
            github.com/cli/cli/pkg/cmd/run/view/view.go:148 +0x1e8
    github.com/spf13/cobra.(*Command).execute(0xc00092a000, 0xc000966280, 0x5, 0x5, 0xc00092a000, 0xc000966280)
            github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
    github.com/spf13/cobra.(*Command).ExecuteC(0xc0008faf00, 0xc00096ca80, 0x1b40301, 0xd)
            github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
    main.mainRun(0xc0000a0058)
            github.com/cli/cli/cmd/gh/main.go:166 +0x676
    main.main()
            github.com/cli/cli/cmd/gh/main.go:46 +0x25
    

Expected vs actual behavior

Expected: show the logs for this job, and do not treat special characters like + and * as regex operators.

Logs

As above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issuehelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions