PowerShell / TextUtility

Microsoft.PowerShell.TextUtility module
MIT License
64 stars 18 forks source link

ConvertFrom-TextTable yum repolist --all fails #39

Open ThomasNieto opened 1 year ago

ThomasNieto commented 1 year ago

Prerequisites

Steps to reproduce

If you try to parse yum repolist --all | ConvertFrom-TextTable -Skip 4 it will error.

Here is the output from yum.

Updating Subscription Management repositories.
Unable to read consumer identity
Subscription Manager is operating in container mode.

This system is not registered with an entitlement server. You can use subscription-manager to register.

repo id                               repo name                                                           status
packages-microsoft-com-prod           packages-microsoft-com-prod                                         enabled
ubi-8-appstream-debug-rpms            Red Hat Universal Base Image 8 (Debug RPMs) - AppStream             disabled
ubi-8-appstream-rpms                  Red Hat Universal Base Image 8 (RPMs) - AppStream                   enabled
ubi-8-appstream-source                Red Hat Universal Base Image 8 (Source RPMs) - AppStream            disabled
ubi-8-baseos-debug-rpms               Red Hat Universal Base Image 8 (Debug RPMs) - BaseOS                disabled
ubi-8-baseos-rpms                     Red Hat Universal Base Image 8 (RPMs) - BaseOS                      enabled
ubi-8-baseos-source                   Red Hat Universal Base Image 8 (Source RPMs) - BaseOS               disabled
ubi-8-codeready-builder               Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder           disabled
ubi-8-codeready-builder-debug-rpms    Red Hat Universal Base Image 8 (Debug RPMs) - CodeReady Builder     disabled
ubi-8-codeready-builder-rpms          Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder           enabled
ubi-8-codeready-builder-source        Red Hat Universal Base Image 8 (Source RPMs) - CodeReady Builder    disabled

Expected behavior

parses

Actual behavior

ConvertFrom-TextTable: Cannot process argument because the value of argument "name" is not valid. Change the value of the "name" argument and run the operation again.

Error details

Exception             :
    Type        : System.Management.Automation.PSArgumentException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Cannot process argument because the value of argument "name" is not valid. Change the value
 of the "name" argument and run the operation again.
            HResult : -2146233087
        CategoryInfo          : InvalidArgument: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : Argument
    Message     : Cannot process argument because the value of argument "name" is not valid. Change the value of
the "name" argument and run the operation again.
    ParamName   : name
    TargetSite  : Void .ctor(System.String, System.Object)
    Source      : System.Management.Automation
    HResult     : -2147024809
    StackTrace  :
   at System.Management.Automation.PSNoteProperty..ctor(String name, Object value)
   at TextTableParser.ConvertTextTableCommand.GetPsObject(List`1 cInfos, String line, String[] columnHeaders) in
D:\a\_work\1\s\TextUtility\src\code\TextTableParser.cs:line 242
   at TextTableParser.ConvertTextTableCommand.Emit(String line) in D:\a\_work\1\s\TextUtility\src\code\TextTableP
arser.cs:line 167
   at TextTableParser.ConvertTextTableCommand.EndProcessing() in D:\a\_work\1\s\TextUtility\src\code\TextTablePar
ser.cs:line 150
   at System.Management.Automation.CommandProcessorBase.Complete()
CategoryInfo          : InvalidArgument: (:) [ConvertFrom-TextTable], PSArgumentException
FullyQualifiedErrorId : Argument,TextTableParser.ConvertTextTableCommand
InvocationInfo        :
    MyCommand        : ConvertFrom-TextTable
    ScriptLineNumber : 1
    OffsetInLine     : 22
    HistoryId        : 165
    Line             : yum repolist --all | ConvertFrom-TextTable -Skip 4
    PositionMessage  : At line:1 char:22
                       + yum repolist --all | ConvertFrom-TextTable -Skip 4
                       +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : ConvertFrom-TextTable
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

7.4

Version

0.5.0

Visuals

No response

ThomasNieto commented 5 months ago

This may be caused by a space in the second column. The parser is able to handle renaming spaces to underscore in the first column.