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

Non tabular output denied for CSV conversion #13737

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

jyejare
Copy link
Member

@jyejare jyejare commented Jan 11, 2024

Problem Statement

The CLI command output containing non-tabular string is not eligible for CSV conversation.

e.g:

STDOUT like

stdout:
    Added Rpms: 32, Errata: 4
    Total steps: 84/84
    --------------------------------
    Associating Content: 39/39
    Downloading Artifacts: 0/0
    Downloading Metadata Files: 6/6
    Parsed Advisories: 4/4
    Parsed Comps: 3/3
    Parsed Packages: 32/32
    Skipping Packages: 0/0
    Un-Associating Content: 0/0

Here zipping in csv conversion function trying to zip the first row of 2 key_value pairs Added Rpms: 32, Errata: 4 with 1 row of key_value from next line Total steps: 84/84. Since strict is set to True the numbe of contents from first row and second row should match which does match with the tabular format but not the above-like output. Making the the strict zipping to fail.

Solution

Returning the output as is if the output is not sniffed using CSV Sniffer for CSV conversion eligibility.

Trying to make it simple though, we could also return all key-value pairs from such output but if the Team demands for it! Since its not returning all key value pairs for such output nobody complaints about it in the past so for now we should be good with the simple solution.

Related Issues

@jyejare jyejare requested a review from a team as a code owner January 11, 2024 10:34
@jyejare jyejare added 6.12.z Introduced in or relating directly to Satellite 6.12 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 Urgent Priority Get this done now Framework Changes A modification of the robottelo framework Critical Severity CherryPick PR needs CherryPick to previous branches labels Jan 11, 2024
@jyejare
Copy link
Member Author

jyejare commented Jan 11, 2024

trigger: test-robottelo

@jyejare
Copy link
Member Author

jyejare commented Jan 11, 2024

trigger: test-robottelo

@lhellebr
Copy link
Contributor

This broke csv parsing for (valid) csvs without delimiters, e.g.:

Message
Using configured credentials for user 'foobar'.

Because sniffer can't find a delimiter and thinks it's not a csv. But it is, it has one column called Message and one row with the actual message.

>>> import csv
>>> sniffer = csv.Sniffer()
>>> output = "Message\nUsing configured credentials for user 'foobar'.\n"
>>> sniffer.sniff(output)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.12/csv.py", line 194, in sniff
    raise Error("Could not determine delimiter")
_csv.Error: Could not determine delimiter

@lhellebr
Copy link
Contributor

I see there are already some workarounds by @ogajduse and @pondrejk . I can add another for my case. Is it a good way though? Are we gonna add more and more exceptions? Opinions?

@jyejare
Copy link
Member Author

jyejare commented Mar 15, 2024

@lhellebr For now please add the w/o similar to @pondrejk has added but we are looking for a better solution and have some options in hand.

@pondrejk do you have the results at hand from those options ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.12.z Introduced in or relating directly to Satellite 6.12 6.13.z Introduced in or relating directly to Satellite 6.13 6.14.z Introduced in or relating directly to Satellite 6.14 6.15.z Introduced in or relating directly to Satellite 6.15 CherryPick PR needs CherryPick to previous branches Critical Severity Framework Changes A modification of the robottelo framework Urgent Priority Get this done now
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants