* [pve-devel] [PATCH manager] fix #4333: redirect API handler output to STDERR
@ 2023-03-08 11:47 Fabian Grünbichler
2023-03-11 17:10 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Grünbichler @ 2023-03-08 11:47 UTC (permalink / raw)
To: pve-devel
otherwise, print/warn statements by the API endpoint are included in the
output, which breaks JSON parsing in case of output-format == json*.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
Notes:
technically a change that might require adapting some scripted calls, although
we don't give any guarantees about pvesh output (or task log contents/stdout
output of endpoints) I think ;)
Suggested-by: reitermarkus (Proxmox Community Forum user)
PVE/CLI/pvesh.pm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/PVE/CLI/pvesh.pm b/PVE/CLI/pvesh.pm
index 9acf292a..31dce26d 100755
--- a/PVE/CLI/pvesh.pm
+++ b/PVE/CLI/pvesh.pm
@@ -309,7 +309,13 @@ sub call_api_method {
$param->{$p} = $uri_param->{$p};
}
- $data = $handler->handle($info, $param);
+ do {
+ # redirect stray output to STDERR
+ # only the returned $data should go to STDOUT
+ local *STDOUT;
+ open(STDOUT, '>&', STDERR);
+ $data = $handler->handle($info, $param);
+ };
}
return if $opt_nooutput || $stdopts->{quiet};
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH manager] fix #4333: redirect API handler output to STDERR
2023-03-08 11:47 [pve-devel] [PATCH manager] fix #4333: redirect API handler output to STDERR Fabian Grünbichler
@ 2023-03-11 17:10 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-03-11 17:10 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Grünbichler
Am 08/03/2023 um 12:47 schrieb Fabian Grünbichler:
> otherwise, print/warn statements by the API endpoint are included in the
> output, which breaks JSON parsing in case of output-format == json*.
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
>
> Notes:
> technically a change that might require adapting some scripted calls, although
> we don't give any guarantees about pvesh output (or task log contents/stdout
> output of endpoints) I think ;)
>
> Suggested-by: reitermarkus (Proxmox Community Forum user)
>
> PVE/CLI/pvesh.pm | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-11 17:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 11:47 [pve-devel] [PATCH manager] fix #4333: redirect API handler output to STDERR Fabian Grünbichler
2023-03-11 17:10 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox