Skip to content

Can't Download Non-Zipped Artifacts #13012

Open

Description

@dsanders11

Describe the bug

Can't download non-zipped artifacts that were uploaded with archive: false.

Affected version

gh version 2.88.1 (2026-03-12)
https://github.com/cli/cli/releases/tag/v2.88.1

Steps to reproduce the behavior

  1. Upload non-zipped artifact in GHA using actions/upload-artifact with archive: false
  2. Try to download the artifact with gh run download
  3. Get an error message: error downloading <artifact>: error extracting zip archive: zip: not a valid zip file

Expected vs actual behavior

Expected to be able to download non-zipped artifacts after they were announced, but the CLI tries to unzip all artifacts.

Pinned by williammartin

Activity

  1. williammartin commented on Mar 25, 2026

    @williammartin
    Member

    Cool, I didn't know about this feature. I think my main concern is where the file should be placed. With the implementation in your PR, and not providing the -n flag, we end up with files being downloaded to ./foo.txt/foo.txt which is kind of weird? I also don't know whether filenames get the same sanitization as the archive names. It seems like on Actions when archive: false, the name key is ignored?

  2. added
    gh-runrelating to the gh run command
    enhancementa request to improve CLI
    and removed on Mar 25, 2026
  3. github-actions commented on Mar 25, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  4. williammartin commented on Mar 25, 2026

    @williammartin
    Member

    After talking about it with @BagToad we think that unarchived artifacts should be downloaded as if -n had been passed.

    Acceptance Criteria

    Scenario 1

    Given I have uploaded an artifact during a workflow with the following step:

    - uses: actions/upload-artifact@v7
      with:
        name: my-non-zipped-artifact
        path: ./world.txt
        archive: false
    

    When I run gh run download <run_id>
    Then the file exists under './world.txt'

    Scenario 2

    Given I have uploaded an artifact during a workflow with the following step:

    - uses: actions/upload-artifact@v7
      with:
        name: my-non-zipped-artifact
        path: ./world.txt
        archive: false
    

    When I run gh run download-n 'world.txt' <run_id>
    Then the file exists under './world.txt'

    Scenario 3

    When I run gh run download --help
    Then I see an explanation of this new behaviour

  5. williammartin commented on Mar 25, 2026

    @williammartin
    Member

    For maintainers, this acceptance test should cover this case:

    # Set up env
    env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
    
    # Use gh as a credential helper
    exec gh auth setup-git
    
    # Create a repository with a file so it has a default branch
    exec gh repo create ${ORG}/${REPO} --add-readme --private
    
    # Defer repo cleanup
    defer gh repo delete --yes ${ORG}/${REPO}
    
    # Clone the repo
    exec gh repo clone ${ORG}/${REPO}
    
    # commit the workflow file
    cd ${REPO}
    exec git config user.email "[email protected]"
    exec git config user.name "Test User"
    mkdir .github/workflows
    mv ../workflow.yml .github/workflows/workflow.yml
    exec git add .github/workflows/workflow.yml
    exec git commit -m 'Create workflow file'
    exec git push -u origin main
    
    # Sleep because it takes a second for the workflow to register
    sleep 1
    
    # Check the workflow is indeed created
    exec gh workflow list
    stdout 'Test Workflow Name'
    
    # Run the workflow
    exec gh workflow run 'Test Workflow Name'
    
    # It takes some time for a workflow run to register
    sleep 10
    
    # Get the run ID we want to watch
    exec gh run list --json databaseId --jq '.[0].databaseId'
    stdout2env RUN_ID
    
    # Wait for workflow to complete
    exec gh run watch ${RUN_ID} --exit-status
    
    # Download all artifacts (includes both zipped and non-zipped)
    exec gh run download ${RUN_ID}
    
    # Check that we downloaded the zipped artifact and extracted into a dir with its name
    exists ./my-zipped-artifact/hello.txt
    
    # Non-zipped artifacts should be downloaded directly to the destination dir, not isolated
    exists ./world.txt
    
    # Clean up
    rm ./my-zipped-artifact
    rm ./world.txt
    
    # Download only the non-zipped artifact by name to current dir
    exec gh run download -n 'world.txt' ${RUN_ID}
    
    # Check that we downloaded the non-zipped artifact into the current dir
    exists ./world.txt
    
    -- workflow.yml --
    name: Test Workflow Name
    
    on:
      workflow_dispatch:
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
          - run: |
              echo hello > hello.txt
              echo world > world.txt
    
          - uses: actions/upload-artifact@v7
            with:
              name: my-zipped-artifact
              path: ./hello.txt
              archive: true
    
          - uses: actions/upload-artifact@v7
            with:
              name: my-non-zipped-artifact
              path: ./world.txt
              archive: false
    
  6. williammartin commented on Mar 25, 2026

    @williammartin
    Member

    I've marked this help wanted for your PR #13013.

  7. iTrooz commented on May 7, 2026

    @iTrooz

    Note: related to #12435

  8. kambala-decapitator commented on Jun 18, 2026

    @kambala-decapitator

    the -n workaround doesn't work currently:

    > gh run download 27698677946 \
                   --repo vcmi/vcmi-dependencies \
                   --dir asd \
                   -n "dependencies-ios.txz"
    error downloading dependencies-ios.txz: error extracting zip archive: zip: not a valid zip file
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLIgh-runrelating to the gh run commandhelp wantedContributions welcome

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions