Skip to content

Exporting gh secret list should always provide number of selected repositories #8679

@nvincent-vossloh

Description

@nvincent-vossloh

Describe the bug

When using gh secret list -o <org> --json 'name,numSelectedRepos' and sending the output to a file or to another process, the integers from numSelectedRepos are set to 0. However if the standard output is the interactive terminal, then the values are correct

gh version: 2.43.1, happens all the way back to 2.36.0 when --json option appeared.

I have only seen this behavior with gh secret list, I could not reproduce it with gh issue -R zephyrproject-rtos/zephyr list --json 'number' | cat - for instance.

Steps to reproduce the behavior

  1. Create a github organisation dummyOrg
  2. Create at least one repository inside dummyOrg
  3. Create a secret at the organisation level and share that secret with the repository created in previous step
  4. List secret at organisation level with json formatting: gh secret list -o dummyOrg --json 'name,numSelectedRepos' | cat -
  5. the numSelectedRepos field is set to zero instead of 1.

Expected vs actual behavior

I am expecting the numSelectedRepos field to have a consistent value when piping the output of gh secret list command or sending it to the terminal

Logs

Sending output to terminal (expected behavior)

gh secret list -o dummyOrg --json 'name,numSelectedRepos'
[
  {
    "name": "MYSECRET",
    "numSelectedRepos": 1
  }
]

Sending output to another process (unexpected behavior)

gh secret list -o dummyOrg --json 'name,numSelectedRepos' | cat -
[{"name":"MYSECRET","numSelectedRepos":0}]

The numSelectedRepos has been converted to 0, the same unexpected behavior occurs with jq instead of cat - or sending the output to a file ( > file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-secretrelating to the gh secret commandhelp wantedContributions welcomep3Affects 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