Open
Description
Describe the bug
We use a series of yq queries to extract paths from gitlab ci yamls to scan script blocks with shellcheck.
Until yq 4.45.2 the query below produced the expected output, but since yq 4.45.3 it produces a different result if the script block is missing.
Version of yq: 4.45.3 and 4.45.4
Operating system: linux
Installed via: docker, binary and snap (all versions have the same issue)
Input Yaml
gitlab-ci.works.yml:
job:
script:
- echo "hello world"
# this job has a script block and should return .["job"]["script"] on eval
gitlab-ci.error.yml:
job:
# this job has no script block and should return .[""] on eval
Command
$ yq eval '.. | ."script"? | select(. != null) | path | ".[\"" + join("\"][\"") + "\"]"' gitlab-ci.works.yml
.["job"]["script"]
$ yq eval '.. | ."script"? | select(. != null) | path | ".[\"" + join("\"][\"") + "\"]"' gitlab-ci.fails.yml
.["
Actual behavior
yq 4.45.3 and 4.45.4 produce the following output:
.["
Expected behavior
yq 4.45.2 and earlier produce the following output:
.[""]