Skip to content

Do not return an error when list commands return an empty list #5472

Closed

Description

@mohd-akram

Describe the bug

A number of list commands (eg. ssh-key, deploy-key, gpg-key) return a non-zero code when the list is empty. This is incorrect, and makes it difficult to distinguish between an empty list, which there is nothing wrong with, and an actual error. I ran into this while creating a script for adding deploy keys. The GitHub API returns an error if you try to add the same key (even if it's in the same repo). To avert that, I check the list first, but this throws an error when the list is empty.

Steps to reproduce the behavior

  1. Type this 'gh deploy-key list'

Expected vs actual behavior

List commands should return success for empty lists, not an error as is currently the case.

Logs

$ gh repo deploy-key list; echo error: $?
No deploy keys found in user/repo
error: 1

Activity

  1. added
    bug
    on Apr 17, 2022
  2. added
    needs-triage
    on Apr 17, 2022
  3. samcoe commented on Apr 18, 2022

    @samcoe
    Contributor

    @mohd-akram Agreed that our list commands should not return an error on empty lists. We recently changed this behavior for the extension list command. We are open to pull requests making this change.

  4. added
    priority-3
    help wanted
    and removed
    needs-triage
    on Apr 18, 2022
  5. Griffin641498 commented on Apr 22, 2022

    @Griffin641498
  6. Griffin641498 commented on Apr 22, 2022

    @Griffin641498
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

    bughelp wantedpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions