Bug 2263041

Summary: Hammer "job-invocation create" does not produce clean CSV/JSON format if requested
Product: Red Hat Satellite Reporter: Ondrej Gajdusek <ogajduse>
Component: Tasks PluginAssignee: Oleh Fedorenko <ofedoren>
Status: ON_QA --- QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.15.0CC: aruzicka, ofedoren, rlavi, zhunting
Target Milestone: streamKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-hammer_cli_foreman_tasks-0.0.21 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ondrej Gajdusek 2024-02-06 18:11:34 UTC
Description of problem:
hammer --output=csv nor hammer --output=json does not provide valid output in the requested format. 

Examples:

# hammer --output=csv job-invocation create --inputs="command=echo tYEzvrxBAG" --job-template="Run Command - Script Default" --search-query="name ~ my.host.com" 2> /dev/null
Message,Id
Job invocation 3 created,3
1 task(s), 0 success, 1 fail

# hammer --output=json job-invocation create --inputs="command=echo tYEzvrxBAG" --job-template="Run Command - Script Default" --search-query="name ~ my.host.com" 2> /dev/null
{
  "message": "Job invocation 4 created",
  "id": 4
}
1 task(s), 0 success, 1 fail

Version-Release number of selected component (if applicable):
6.12 (or lower) onwards

How reproducible:
always

Steps to Reproduce:
1.Run `hammer --output=csv job-invocation create` or `hammer --output=json job-invocation create`

Actual results:
There is an extra line on STDOUT that shows the result of the task. This prevents STDOUT from being parsed as JSON or CSV.

Expected results:
No extra line in the requested format.

Comment 1 Oleh Fedorenko 2024-03-14 14:58:59 UTC
Created redmine issue https://projects.theforeman.org/issues/37264 from this bug

Comment 2 Bryan Kearney 2024-03-15 16:03:31 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/37264 has been resolved.