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

When using json() failing command has output on stdout and not stderr #90

Open
bambamboole opened this issue May 7, 2023 · 13 comments
Open

Comments

@bambamboole
Copy link
Contributor

When the option json() is turned on, a not successful execution has its output in on stdout and not on stderr.

I am not sure whats the best way to get around the issue, that a failing execution does not output anything

Option 1:
Check in runProcess if the ANSIBLE_STDOUT_CALLBACK is set to json and then return $process->getOutput() instead of $process->getErrorOutput().

Option 2:
Make the process accesible from the outside and make the user responsible to get the right output

Option 3:
just always return $process->getOutput() (don't know how it's without json enabled)

@bambamboole
Copy link
Contributor Author

@maschmann do you accept a PR for one of these cases?

@maschmann
Copy link
Owner

Hi,
sorry for taking that long to react.
Since we're already handling output from the process in case of errors, it's way easier to check if JSON output is used and accordingly return the STDOUT instead of STDERR. In my opinion this is more consistent behavior.

@maschmann
Copy link
Owner

@bambamboole
Copy link
Contributor Author

@maschmann thats absolutely fine. This would also solve my issue (which leads to no need of my fork anymore) 🚀

@maschmann
Copy link
Owner

Would be great if you could also tests this in your environment. Worked fine for me, but the more testing, the better :-)

@bambamboole
Copy link
Contributor Author

ok, but then I need a few days.

@maschmann
Copy link
Owner

Just let me know if got around to testing it - I'll be around a bit more frequent than the past months.
The other option would be to release an early version of all the recent changes and letting it run for a while.
Since there are lots of deprecations and new dependency versions, breaking bc, it warrants a new "major" version - so it should be a concious decision to update/upgrade for anyone.

@bambamboole
Copy link
Contributor Author

Could be a 5.0.0-rc1

@maschmann
Copy link
Owner

Exactly - I'd include the host sprintf change you made and prepare the rc 👍

maschmann added a commit that referenced this issue Oct 1, 2024
* drop PHP versions below 8.1
* update dependencies
* merge fix for When using json() failing command has output on stdout and not stderr #90
* add symfony process 7 Adding support of symfony/process ^7.0 #94
* add docker env for develeopment
* update phpunit, fix tests to work with v11
@maschmann
Copy link
Owner

Hi @bambamboole, I've added most changes to the rc. You'd still have to contribute the sprintf change for hosts. Otherwise I'm pretty sure, we're mostly through.

@bambamboole
Copy link
Contributor Author

will check in the evening ! thx for reminding me.

@bambamboole
Copy link
Contributor Author

I think you merged it here. I just had it also in the other PR, but made a separate PR for it. Here it is in main.

@maschmann
Copy link
Owner

Thanks, totally missed that 🙄 . So, great, works again!
If you don't find any other issues, i'll build the release within the next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants