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

Wildcard does not handle hyphens in matching key #2042

Closed
egnoriega opened this issue May 14, 2024 · 0 comments
Closed

Wildcard does not handle hyphens in matching key #2042

egnoriega opened this issue May 14, 2024 · 0 comments
Labels

Comments

@egnoriega
Copy link

Describe the bug
When using a wildcard (asterisk or splat), which matches a key with hyphen, the command fails. The key is unknown at the start and so need to use a wildcard to match.

Version of yq: yq (https://github.com/mikefarah/yq/) version v4.44.
Operating system: mac
Installed via: homebrew

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.yml:

verify-cluster-running:
  stage: e2e-tests
  image: repo.io/wirecut/python:v3.10.11

Command

Actual behavior

bash-5.2$ yq -e '.verify-cluster-running.image|type == "!!str"' files/e2e-tests/alpha.yml
true
bash-5.2$ yq -e '.*.image|type == "!!str"' files/e2e-tests/alpha.yml
Error: cannot index array with 'image' (strconv.ParseInt: parsing "image": invalid syntax)
bash-5.2$ yq -e '.[].image|type == "!!str"' files/e2e-tests/alpha.yml
Error: cannot index array with 'image' (strconv.ParseInt: parsing "image": invalid syntax)
bash-5.2$ yq -e '."[]".image|type == "!!str"' files/e2e-tests/alpha.yml
false
Error: no matches found

Expected behavior

bash-5.2$ yq -e '.*.image|type == "!!str"' files/e2e-tests/alpha.yml
true

Additional context
This works with entries which do not have a hyphen in the file.

@egnoriega egnoriega changed the title Wiledard does not handle hyphens in matching key Wildcard does not handle hyphens in matching key May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant