Skip to content
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

erroneously including invalid aliases when the jq expression returns "null" but there is valid string data from the expression #36

Closed
rocktavious opened this issue May 29, 2021 · 2 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@rocktavious
Copy link
Collaborator

rocktavious commented May 29, 2021

"Aliases": [
            "k8s:yellow-app1b-contact-extractor-deployment-yellow-app1b-ml-consumers",
            "k8s:null"
        ],

this should probably not happen and we should just drop the value but its not a simple fix because it was a valid parse of the JQ expression and returned a non-null string value because of the nature of it being a JQ string expression filter.

> echo '{}' | jq '"k8s:\(.metadata.name)"'
"k8s:null"    <- valid non-null string value which we propagate because its valid string data
> echo '{}' | jq '.metadata.name'  
null          <- json null value which we detect as null
@rocktavious rocktavious changed the title bugfix: erroneously including invalid aliases when the jq expression returns "null" but there is valid string data from the expression erroneously including invalid aliases when the jq expression returns "null" but there is valid string data from the expression Jun 3, 2021
@rocktavious rocktavious added the question Further information is requested label Jun 3, 2021
@rocktavious
Copy link
Collaborator Author

I think the only fix we can suggest here is to use JQ logic to check if the lookup was null and then emit the string or null

> echo '{}' | jq '"k8s:\(.metadata.name)"'
"k8s:null" 

VS

> echo '{}' | jq '.metadata.name if . then "k8s:\(.)" else empty end'
null
> echo '{"metadata":{"name":"hello"}}' | jq '.metadata.name | if . then "k8s:\(.)" else empty end'
"k8s:hello"

@taimoorgit
Copy link
Contributor

Closing because:

  1. This has a wontfix tag and the issue is inactive
  2. We fixed a very similar issue with null and jq expressions in the latest release: https://github.com/OpsLevel/opslevel-jq-parser/releases/tag/v2024.3.15

@taimoorgit taimoorgit closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants