Skip to content

bug(?): tab completing [ causes an error to be logged #17542

@insomnimus

Description

@insomnimus

Prerequisites

Steps to reproduce

Given the full and only command line:

[

Pressing tab at the end of the buffer (right after the bracket) causes an error to be logged to $Error.

Expected behavior

No error to be logged to `$Error`, even if no completion is produced.

Actual behavior

An error is logged to `$Error` right after pressing tab.

Error details

Type           : System.Management.Automation.CmdletInvocationException
ErrorRecord    : 
    Exception             : 
        Type        : System.Management.Automation.WildcardPatternException
        ErrorRecord : 
            Exception             : 
                Type    : System.Management.Automation.ParentContainsErrorRecordException
                Message : The specified wildcard character pattern is not valid: \[*
                HResult : -2146233087
            CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
            FullyQualifiedErrorId : RuntimeException
        TargetSite  : 
            Name          : Parse
            DeclaringType : System.Management.Automation.WildcardPatternParser, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
            MemberType    : Method
            Module        : System.Management.Automation.dll
        Message     : The specified wildcard character pattern is not valid: \[*
        Source      : System.Management.Automation
        HResult     : -2146233087
        StackTrace  : 
   at System.Management.Automation.WildcardPatternParser.Parse(WildcardPattern pattern, WildcardPatternParser parser)
   at System.Management.Automation.WildcardPatternMatcher.MyWildcardPatternParser.Parse(WildcardPattern pattern, CharacterNormalizer characterNormalizer)
   at System.Management.Automation.WildcardPatternMatcher..ctor(WildcardPattern wildcardPattern)
   at System.Management.Automation.WildcardPattern.Init()
   at System.Management.Automation.LocationGlobber.IsChildNameAMatch(PSObject childObject, WildcardPattern stringMatcher, Collection`1 includeMatcher, Collection`1 excludeMatcher, String& childName)
   at System.Management.Automation.LocationGlobber.GenerateNewPSPathsWithGlobLeaf(List`1 currentDirs, PSDriveInfo drive, String leafElement, Boolean isLastLeaf, ContainerCmdletProvider provider, CmdletProviderContext context)
   at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths, PSDriveInfo drive, ContainerCmdletProvider provider, CmdletProviderContext context)
   at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
   at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance)
   at System.Management.Automation.PathIntrinsics.GetResolvedPSPathFromPSPath(String path, CmdletProviderContext context)
   at Microsoft.PowerShell.Commands.ResolvePathCommand.ProcessRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
    CategoryInfo          : NotSpecified: (:) [Resolve-Path], WildcardPatternException
    FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ResolvePathCommand
    InvocationInfo        : 
        MyCommand       : Resolve-Path
        HistoryId       : 2
        InvocationName  : Microsoft.PowerShell.Management\Resolve-Path
        CommandOrigin   : Internal
    ScriptStackTrace      : at <ScriptBlock><End>, <No file>: line 38
    PipelineIterationInfo : 



TargetSite     : 
    Name          : Invoke
    DeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    MemberType    : Method
    Module        : System.Management.Automation.dll
Message        : The specified wildcard character pattern is not valid: \[*
InnerException : 
    Type        : System.Management.Automation.WildcardPatternException
    ErrorRecord : 
        Exception             : 
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : The specified wildcard character pattern is not valid: \[*
            HResult : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : RuntimeException
    TargetSite  : 
        Name          : Parse
        DeclaringType : System.Management.Automation.WildcardPatternParser, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message     : The specified wildcard character pattern is not valid: \[*
    Source      : System.Management.Automation
    HResult     : -2146233087
    StackTrace  : 
   at System.Management.Automation.WildcardPatternParser.Parse(WildcardPattern pattern, WildcardPatternParser parser)
   at System.Management.Automation.WildcardPatternMatcher.MyWildcardPatternParser.Parse(WildcardPattern pattern, CharacterNormalizer characterNormalizer)
   at System.Management.Automation.WildcardPatternMatcher..ctor(WildcardPattern wildcardPattern)
   at System.Management.Automation.WildcardPattern.Init()
   at System.Management.Automation.LocationGlobber.IsChildNameAMatch(PSObject childObject, WildcardPattern stringMatcher, Collection`1 includeMatcher, Collection`1 excludeMatcher, String& childName)
   at System.Management.Automation.LocationGlobber.GenerateNewPSPathsWithGlobLeaf(List`1 currentDirs, PSDriveInfo drive, String leafElement, Boolean isLastLeaf, ContainerCmdletProvider provider, CmdletProviderContext context)
   at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths, PSDriveInfo drive, ContainerCmdletProvider provider, CmdletProviderContext context)
   at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
   at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance)
   at System.Management.Automation.PathIntrinsics.GetResolvedPSPathFromPSPath(String path, CmdletProviderContext context)
   at Microsoft.PowerShell.Commands.ResolvePathCommand.ProcessRecord()
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
Source         : System.Management.Automation
HResult        : -2146233087
StackTrace     : 
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
   at System.Management.Automation.PowerShellExecutionHelper.ExecuteCurrentPowerShell(Exception& exceptionThrown, IEnumerable input)


### Environment data

```powershell
Name                           Value
----                           -----
PSVersion                      7.2.4
PSEdition                      Core
GitCommitId                    7.2.4
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


### Visuals

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions