Upload-artifact: sanitize artifact names

Created on 21 May 2020  路  5Comments  路  Source: actions/upload-artifact

Describe the bug

I'm running a job matrix including with env variables like foo/bar. The artifact names should reflect those env variables, however the name may not contain special characters like a /. It would be convenient to replace non supported characters by _.

Version

  • [ ] V1
  • [x] V2

*Environment

  • [ ] self-hosted
  • [ ] Linux
  • [ ] Windows
  • [ ] Mac

How to reproduce

Try to create a artifact with the name foo/bar

wontfix

Most helpful comment

I'm inclined to mark this as wontfix @yacaovsnc @joshmgross thoughts?

A couple of reasons why I think this should be wontfix

  • The error message is very clear
  • We have clear documentation as to why these restriction exists
  • Relatively simple for users to change the artifact name themselves in some other step or in their YAML.
  • If the artifact name get sanitized automatically, this can catch users off guard as a different artifact name would manifest itself in the UI. We could add a warning or something, however I'm sure some other users would file issues and ask for no sanitization or inquire about why their name is getting changed automatically.
  • We would also have to sanitize the artifact name on the download-artifact side if we decide to do this so the same artifact gets downloaded. This would be particularly confusing too because if users used the artifact name in another step (in some cases, a folder denoted by the name of the artifact gets created), their path would could be messed up so it's best if we let users just change it themselves.

Overall I don't think the trade-off is worth it.

All 5 comments

Ouhh this isn't really a bug but a feature. Can't remove the bug label sorry.

image

A solution is the following, however I'd prefer having this the default:

    - name: sanitize target
      run: echo ::set-env name=TARGET_SANI::$(echo ${{ matrix.target }} | tr "/" "_")

    - uses: actions/upload-artifact@v2
      with:
        name: ${{ env.TARGET_SANI }}

I'm inclined to mark this as wontfix @yacaovsnc @joshmgross thoughts?

A couple of reasons why I think this should be wontfix

  • The error message is very clear
  • We have clear documentation as to why these restriction exists
  • Relatively simple for users to change the artifact name themselves in some other step or in their YAML.
  • If the artifact name get sanitized automatically, this can catch users off guard as a different artifact name would manifest itself in the UI. We could add a warning or something, however I'm sure some other users would file issues and ask for no sanitization or inquire about why their name is getting changed automatically.
  • We would also have to sanitize the artifact name on the download-artifact side if we decide to do this so the same artifact gets downloaded. This would be particularly confusing too because if users used the artifact name in another step (in some cases, a folder denoted by the name of the artifact gets created), their path would could be messed up so it's best if we let users just change it themselves.

Overall I don't think the trade-off is worth it.

Makes sense.

Was this page helpful?
0 / 5 - 0 ratings