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

safelyRenameFile errors do not exit with error code #1062

Closed
chrispsplash opened this issue Jan 3, 2022 · 2 comments
Closed

safelyRenameFile errors do not exit with error code #1062

chrispsplash opened this issue Jan 3, 2022 · 2 comments
Labels

Comments

@chrispsplash
Copy link

chrispsplash commented Jan 3, 2022

Describe the bug
If you get a safelyRenameFile error while using --inplace the process exits with status 0, indicating there was no error, without updating the file.

Version of yq: 4.16.2
Operating system: official docker container
Installed via: official docker container: mikefarah/yq:4.16.2

Reproduction
This Dockerfile (below 1) reproduces the error. Just build it and run to demonstrate (below 2)

Dockerfile

FROM mikefarah/yq:4.16.2

USER root

RUN echo -e 'foobar: baz' > /etc/tmp.yaml

USER yq

ENTRYPOINT []
CMD yq e '.foobar="hello"' -i /etc/tmp.yaml; echo exit code: $?

Build and run

docker build . -t yq-issue1062
docker run yq-issue1062

Actual behavior
Prints the error below but exits with code 0

22:50:44 safelyRenameFile [ERRO] Failed copying from /tmp/temp272450726 to /etc/tmp.yaml
22:50:44 safelyRenameFile [ERRO] open /etc/tmp.yaml: permission denied

Expected behavior
Prints the error above and exits with non-zero code

@mikefarah
Copy link
Owner

Thanks for the reproducible docker, this will be fixed in the next release.

@mikefarah
Copy link
Owner

Oh git autoclosed this :/ anyway the docker image 4.17.2 has the fix!

frerikandriessen added a commit to frerikandriessen/catalog that referenced this issue Sep 27, 2022
Because of this, the task will now fail when a command exited with a
non-zero exit code. This was a bug in previous yq versions, see:
mikefarah/yq#1062
frerikandriessen added a commit to frerikandriessen/catalog that referenced this issue Oct 10, 2022
* Add backwards compatibility for previous version
* Update default image
* Ensure the task will now fail when a command exited with a
non-zero exit code. This was a bug in previous yq versions, see:
mikefarah/yq#1062
* Add optional result
* Add default value for SCRIPT for backwards compatibility
* Handle empty SCRIPT param
frerikandriessen added a commit to frerikandriessen/catalog that referenced this issue Oct 10, 2022
* Add backwards compatibility for previous version
* Update default image
* Ensure the task will now fail when a command exited with a
non-zero exit code. This was a bug in previous yq versions, see:
mikefarah/yq#1062
* Add optional result
* Add default value for SCRIPT for backwards compatibility
* Handle empty SCRIPT param
frerikandriessen added a commit to frerikandriessen/catalog that referenced this issue Oct 10, 2022
* Add backwards compatibility for previous version
* Update default image
* Ensure the task will now fail when a command exited with a
non-zero exit code. This was a bug in previous yq versions, see:
mikefarah/yq#1062
* Add optional result
* Add default value for SCRIPT for backwards compatibility
* Handle empty SCRIPT param
tekton-robot pushed a commit to tektoncd/catalog that referenced this issue Oct 11, 2022
* Add backwards compatibility for previous version
* Update default image
* Ensure the task will now fail when a command exited with a
non-zero exit code. This was a bug in previous yq versions, see:
mikefarah/yq#1062
* Add optional result
* Add default value for SCRIPT for backwards compatibility
* Handle empty SCRIPT param
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