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

Incorrect JMESPath result with text output format #8998

Closed
1 task
jack-parsons-bjss opened this issue Oct 21, 2024 · 4 comments
Closed
1 task

Incorrect JMESPath result with text output format #8998

jack-parsons-bjss opened this issue Oct 21, 2024 · 4 comments
Assignees
Labels

Comments

@jack-parsons-bjss
Copy link

Describe the bug

When the text output format is selected, results returned are inconsistent from the json output (and a test on jmespath.org, which is consistent with the json format).
We are running the following query: sort_by(imageDetails[? !(contains(imageTags[0], feature-branch))], & imagePushedAt)[-1].imageTags[0] on an aws ecr describe-images CLI call which ultimately results in more than one page of results being returned.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

I expect only the latest non feature branch version to be returned; in our case, 1.0.0-49

Current Behavior

I get that query executed on every page of results returned - 1.0.0-49 plus 1.0.0-18 by default, but by configuring the --page-size argument I can get more results.

Reproduction Steps

aws ec2 describe-images --owners amazon --query 'sort_by(Images[], & CreationDate)[-1].ImageId' --output text --page-size 100

Possible Solution

No response

Additional Information/Context

No response

CLI version used

aws-cli/2.17.42 Python/3.11.9 Darwin/23.6.0 source/arm64

Environment details (OS name and version, etc.)

MacOS Sonoma 14.7

@jack-parsons-bjss jack-parsons-bjss added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 21, 2024
@tim-finnigan tim-finnigan self-assigned this Oct 29, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. Linking relevant AWS CLI v2 documentation for reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-output-format.html

As noted there, the difference in behavior between --output text and --output json is expected:

image

Regarding pagination, here is documentation with more information on how that works in the AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html

When you specify --page-size for the describe-images command, that parameter is getting sent as MaxResults to the underlying API request. (You can see what the full request looks like when you add the --debug command.). Hope that helps, if you have any follow up questions please let us know.

@tim-finnigan tim-finnigan added ecr response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 29, 2024
@jack-parsons-bjss
Copy link
Author

I understand that changing this behaviour is a breaking change and that you've said that this is expected, but from my perspective as a user this feels very unexpected. Why does changing the output format change the query behaviour rather than just changing how the output is rendered? I suppose I can close this as Won't Fix 🤷

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 30, 2024
@tim-finnigan
Copy link
Contributor

Thanks for following up. I will close this as not planned as it is the expected behavior. I think this comment an older issue explains the reasoning behind the differences in behavior:

Generally the text output is for human readability. The JSON output is designed for scripting, we would suggest using either --query or pipe the JSON output to some other JSON parsing utility.

@tim-finnigan tim-finnigan closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2024
Copy link

github-actions bot commented Nov 4, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

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

2 participants