-
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty docs break sort_by() #2164
Comments
This became very confusing in our custom diffing workflow when we accidentally left extra Would be nice with a cleaner workaround that more expressively filter out empty documents before doing the sort. |
mikefarah
added a commit
that referenced
this issue
Nov 16, 2024
Thanks for raising, will fix in the next release |
Fixed in 4.44.5 |
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this issue
Nov 20, 2024
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [mikefarah/yq](https://github.com/mikefarah/yq) | patch | `v4.44.3` -> `v4.44.5` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>mikefarah/yq (mikefarah/yq)</summary> ### [`v4.44.5`](https://github.com/mikefarah/yq/releases/tag/v4.44.5) [Compare Source](mikefarah/yq@v4.44.3...v4.44.5) - Format comments with a gray foreground (Thanks [@​gabe565](https://github.com/gabe565)) - Fixed handling of nulls with sort_by expressions [#​2164](mikefarah/yq#2164) - Force no color output when NO_COLOR env presents (Thanks [@​narqo](https://github.com/narqo)) - Fixed array subtraction update bug [#​2159](mikefarah/yq#2159) - Fixed index out of range error - Can traverse straight from parent operator (parent.blah) - Bumped dependencies Note: 4.44.4 was skipped as it had a release pipeline failure </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
If there are empty documents passed into eval-all, sorting only works before and after the empty document.
Version of yq: 4.43.1
Operating system: Ubuntu 20.04
Installed via: wget https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_linux_amd64
Input Yaml
data1.yml:
Command
The command you ran:
Actual behavior
Expected behavior
Additional context
It appears that empty documents behave like an ordering boundary, where everything before it is sorted correctly, as is everything after, but not across. Curiously, if instead of
sort_by(.kind, .metadata.name)
I dosort_by("\(.kind), \(.metadata.name)")
everything is sorted correctly.My actual motivation is to compare Kubernetes manifests as in #1101. In my case, the manifests are produced by Helm, which can sometimes emit empty documents if the manifest is not needed.
The text was updated successfully, but these errors were encountered: