Skip to content

jq unique produces null from empty arrays #7001

@ghost

Description

Describe the bug

During a gh pr list with jq filtering, any empty array passed to the unique operator outputs null.

$ gh --version
gh version 2.4.0+dfsg1 (2022-03-23 Ubuntu 2.4.0+dfsg1-2)
https://github.com/cli/cli/releases/latest

Steps to reproduce the behavior

  1. gh pr list --json title -q '[] | unique'
  2. Observe that the output is null

Expected vs actual behavior

Expected output is the empty array ([]). Instead, null is produced.

Logs

$ gh pr list --json title -q '[] | unique'
null

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority-3Affects 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