Skip to content

[System.Management.Automation.CompletionCompleters]::CompleteFilename("") throws NullReferenceException #26277

Description

@teramako

Prerequisites

Steps to reproduce

on 7.6.0-preview.5

[System.Management.Automation.CompletionCompleters]::CompleteFilename("") throws NullReferenceException

Expected behavior

should returns CompletionResult

Actual behavior

PS> [System.Management.Automation.CompletionCompleters]::CompleteFilename("")
MethodInvocationException: Exception calling "CompleteFilename" with "1" argument(s): "Object reference not set to an instance of an object."

Error details

PS> Get-Error -newest 1

Exception             :
    Type           : System.Management.Automation.MethodInvocationException
    ErrorRecord    :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Exception calling "CompleteFilename" with "1" argument(s): "Object reference not set to an instance of an object."
            HResult : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : NullReferenceException
        InvocationInfo        :
            ScriptLineNumber : 1
            OffsetInLine     : 1
            HistoryId        : 1
            Line             : [System.Management.Automation.CompletionCompleters]::CompleteFilename("")
            Statement        : [System.Management.Automation.CompletionCompleters]::CompleteFilename("")
            PositionMessage  : At line:1 char:1
                               + [System.Management.Automation.CompletionCompleters]::CompleteFilename …
                               + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            CommandOrigin    : Internal
        ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    TargetSite     :
        Name          : ConvertToMethodInvocationException
        DeclaringType : [System.Management.Automation.ExceptionHandlingOps]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message        : Exception calling "CompleteFilename" with "1" argument(s): "Object reference not set to an instance of an object."
    Data           :
        System.Management.Automation.Interpreter.InterpretedFrameInfo, System.Management.Automation, Version=7.6.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35 : <ScriptBlock>

    InnerException :
        Type       : System.NullReferenceException
        TargetSite :
            Name          : CompleteFilename
            DeclaringType : [System.Management.Automation.CompletionCompleters]
            MemberType    : Method
            Module        : System.Management.Automation.dll
        Message    : Object reference not set to an instance of an object.
        Source     : System.Management.Automation
        HResult    : -2147467261
        StackTrace :
   at System.Management.Automation.CompletionCompleters.CompleteFilename(CompletionContext context, Boolean containerOnly, HashSet`1 extension)
   at CallSite.Target(Closure, CallSite, Type, String)
    Source         : System.Management.Automation
    HResult        : -2146233087
    StackTrace     :
   at System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
   at CallSite.Target(Closure, CallSite, Type, String)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : NullReferenceException
InvocationInfo        :
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : [System.Management.Automation.CompletionCompleters]::CompleteFilename("")
    Statement        : [System.Management.Automation.CompletionCompleters]::CompleteFilename("")
    PositionMessage  : At line:1 char:1
                       + [System.Management.Automation.CompletionCompleters]::CompleteFilename …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.0-preview.5
PSEdition                      Core
GitCommitId                    7.6.0-preview.5
OS                             Ubuntu 24.04.3 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions