Skip to content
Latchkey

actions/upload-artifact "The artifact name is not valid" in CI

Artifact names cannot contain certain characters: forward slash, backslash, colon, asterisk, question mark, quotes, angle brackets, or pipe. When a name is built from a branch ref or path containing one of these, upload-artifact rejects it with "The artifact name is not valid".

What this error means

The upload step fails with "Error: The artifact name is not valid: <name>. Contains the following character: ...", usually because the name was templated from github.ref or a file path.

upload-artifact
Error: The artifact name is not valid: report-feature/login. Contains the following character: Forward slash /
Invalid characters include: Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return, Line feed, Backslash \\, Forward slash /

Common causes

A branch ref or path used directly in the name

A name like report-${{ github.ref_name }} becomes report-feature/login when the branch has a slash, which is forbidden.

Special characters from a dynamic value

Colons from timestamps, asterisks from globs, or quotes from interpolated strings slip into the name and trip validation.

How to fix it

Sanitize the name before upload

  1. Replace forbidden characters (slashes, colons) with a safe one like a hyphen.
  2. Build the sanitized value in a prior step and reference it.
  3. Re-run with the cleaned name.
.github/workflows/ci.yml
- id: name
  run: echo "value=report-${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
  with:
    name: ${{ steps.name.outputs.value }}
    path: report/

Use only allowed characters

Stick to letters, digits, hyphens, underscores, and dots in artifact names; avoid path separators and punctuation that the validator rejects.

How to prevent it

  • Never template artifact names directly from refs or paths.
  • Sanitize dynamic name components to a safe character set.
  • Keep names to letters, digits, dot, hyphen, and underscore.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →