Skip to content

Error on pressing keys Alt+h when trying to get a description of a parameter #4907

Description

@wrtdghvbn-hash

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.3.6+d2e770f93b7a53d8660a6402eb29d1ae1c35e767
PowerShell: 7.5.2
OS: Microsoft Windows 10.0.26100
BufferWidth: 120
BufferHeight: 26

Last 63 Keys:

 l s Spacebar - p a Tab Alt+h q Ctrl+c U P d a t e Backspace Backspace Backspace Backspace Backspace p d a t e - H e l Tab Spacebar - Y Backspace U i Tab Spacebar E Backspace e n - U S Enter
 c p p Spacebar Backspace Backspace Backspace Backspace l s Spacebar - p a Tab Alt+h

### Exception

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
   at CallSite.Target(Closure, CallSite, Object)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at Microsoft.PowerShell.PSConsoleReadLine.WriteParameterHelp(Object helpContent)
   at Microsoft.PowerShell.PSConsoleReadLine.WriteDynamicHelpContent(String commandName, String parameterName, Boolean isFullHelp)
   at Microsoft.PowerShell.PSConsoleReadLine.DynamicHelpImpl(Boolean isFullHelp)
   at Microsoft.PowerShell.PSConsoleReadLine.ShowParameterHelp(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

Image

Environment data

PS Version: 7.5.2
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.6
PSReadLine EditMode: Windows
OS: 10.0.26100.2308 (WinBuild.160101.0800)
BufferWidth: 156
BufferHeight: 36

Steps to reproduce

Insert any commandlet with parameter, don't press Enter. Press Alt+h to get a hint. The exception occurs both in the terminal and in the console.

Expected behavior

Expecting to receive a short hint on the parameter

Actual behavior

We get an exception

Activity

  1. daxian-dbw commented on Aug 27, 2025

    @daxian-dbw
    Member

    This is strange and it will be helpful if we can check on the helpContent object that is passed to WriteParameterHelp(Object helpContent).

    Can you please run the following script in the same PowerShell session where you can reproduce this issue with Get-ChildItem -LiteralPath and then share the results of the last 3 commands here?

    ## Get the PSReadLine singleton instance
    $t = [Microsoft.PowerShell.PSConsoleReadLine]
    $f = $t.GetField('_singleton', [System.Reflection.BindingFlags]::Static -bor [System.Reflection.BindingFlags]::NonPublic)
    $instance = $f.GetValue($null)
    
    ## Get the method used to retrieve the help content.
    $method = $t.GetMethods([System.Reflection.BindingFlags]::Instance -bor [System.Reflection.BindingFlags]::NonPublic) | ? Name -Like *GetDynamicHelpContent
    
    ## Call the method with reflection
    $v = $method.Invoke($instance, @('Get-ChildItem', 'LiteralPath', $false))
    ## After running the above, please share the results from those 3 commands.
    $v | gm
    $null -eq $v.type
    $v | fl
    
  2. wrtdghvbn-hash commented on Aug 28, 2025

    @wrtdghvbn-hash
    Author

    Good morning. I ran the script several times - before and after installing the help update. When pasting a script, the terminal window once encountered the disappearance of the mouse cursor within the window. But it was not possible to reproduce the problem. Results before "help-update":

    PS C:\Users\user> $v | gm
       TypeName: ExtendedCmdletHelpInfo#parameter
       Name             MemberType   Definition
    ----             ----------   ----------
    Equals           Method       bool Equals(System.Object obj)
    GetHashCode      Method       int GetHashCode()
    GetType          Method       type GetType()
    ToString         Method       string ToString()
    aliases          NoteProperty string aliases=PSPath, LP
    globbing         NoteProperty string globbing=false
    isDynamic        NoteProperty string isDynamic=false
    name             NoteProperty string name=LiteralPath
    parameterSetName NoteProperty string parameterSetName=LiteralItems
    parameterValue   NoteProperty System.String parameterValue=string[]
    pipelineInput    NoteProperty string pipelineInput=true (ByPropertyName)
    position         NoteProperty string position=Named
    required         NoteProperty string required=true
    type             NoteProperty ExtendedCmdletHelpInfo#type type=@{name=string[]}
    
    PS C:\Users\user> $null -eq $v.type
    False
    PS C:\Users\user> $v | fl
    
    name             : LiteralPath
    required         : true
    pipelineInput    : true (ByPropertyName)
    isDynamic        : false
    globbing         : false
    parameterSetName : LiteralItems
    parameterValue   : string[]
    type             : @{name=string[]}
    position         : Named
    aliases          : PSPath, LP
    
  3. wrtdghvbn-hash commented on Aug 28, 2025

    @wrtdghvbn-hash
    Author

    Results after running "update-help":

    PS C:\Users\user> $v | gm
    
       TypeName: MamlCommandHelpInfo#parameter
    
    Name           MemberType   Definition
    ----           ----------   ----------
    Equals         Method       bool Equals(System.Object obj)
    GetHashCode    Method       int GetHashCode()
    GetType        Method       type GetType()
    ToString       Method       string ToString()
    aliases        NoteProperty string aliases=none
    description    NoteProperty psobject[] description=System.Management.Automation.PSObject[]
    globbing       NoteProperty string globbing=false
    name           NoteProperty System.String name=LiteralPath
    parameterValue NoteProperty System.String parameterValue=System.String[]
    pipelineInput  NoteProperty string pipelineInput=false
    position       NoteProperty string position=Named
    required       NoteProperty string required=true
    variableLength NoteProperty string variableLength=false
    
    PS C:\Users\user> $null -eq $v.type
    True
    PS C:\Users\user>
    
    PS C:\Users\user> $v | fl
    
    parameterValue : System.String[]
    description    : {@{Text=Specifies a path to one or more locations. The value of **LiteralPath** is used exactly as it's
                     typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose
                     it in single quotation marks. Single quotation marks tell PowerShell to not interpret any characters
                     as escape sequences.
                     }, @{Text=For more information, see
                     [about_Quoting_Rules](../Microsoft.PowerShell.Core/About/about_Quoting_Rules.md).}}
    name           : LiteralPath
    required       : true
    variableLength : false
    globbing       : false
    pipelineInput  : false
    position       : Named
    aliases        : none
    
    PS C:\Users\user>
    
  4. wrtdghvbn-hash commented on Aug 28, 2025

    @wrtdghvbn-hash
    Author

    And one more problem. I don't know if it is related to the current one, but this is what I get in the file ''C:\Users\user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt''. Instead of command history, I see this:
    PS C:\Users\user> gc 'C:\Users\user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt'
    楨瑳牯൹⠊敇⵴楆敬慈桳ⴠ汁潧楲桴䡓㉁㘵ⴠ慐桴䐠尺潐敷卲敨汬㜭㔮㈮眭湩砭㐶洮楳⸩慨桳ⴠ煥⠠敇⵴楆敬慈桳ⴠ汁潧楲桴䡓㉁㘵ⴠ慐.
    This is a file:

    ConsoleHost_history.txt

    After deleting this file and reopening the terminal, the newly created history file looks normal.

  5. mattcargile commented on Aug 29, 2025

    @mattcargile

    I also get this same stack trace on 7.5.2 and PSReadLine version 2.3.6 with ShowParameterHelp like the below.

    filehash -Algorithm # + <Alt+h>

    filehash is the "secret" shorthand for Get-FileHash.

    Oops, something went wrong.
    Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
    Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
    Thank you!
    
    ### Environment
    PSReadLine: 2.3.6+d2e770f93b7a53d8660a6402eb29d1ae1c35e767
    PowerShell: 7.5.2
    OS: Microsoft Windows 10.0.22631
    BufferWidth: 209
    BufferHeight: 51
    
    Last 200 Keys:
    
     Backspace p s r e a d l i n e o p t i o n Enter
     p s r e a d l i n e k e y h a n d l e r Enter
     UpArrow Spacebar | Spacebar k Backspace ? Spacebar k e y Spacebar - m a Spacebar h Enter
     UpArrow LeftArrow + Enter
     UpArrow LeftArrow LeftArrow LeftArrow RightArrow \ Enter
     l s Spacebar l i p Tab Backspace t Tab Backspace Backspace - l i Backspace Backspace Backspace Backspace Backspace l Backspace Spacebar - l i Tab Alt+h Ctrl+Backspace Ctrl+Backspace Ctrl+Backspace Ctrl+Backspace Ctrl+Backspace g m o Enter
     f d r e s Spacebar p s r e a d l i n e Enter
     f i l e h a s h RightArrow Ctrl+a RightArrow Ctrl+a Backspace g c p Spacebar f i l e h a s h Enter
     UpArrow Ctrl+LeftArrow g e t - Enter
     n i Spacebar t . t x t RightArrow Spacebar | Spacebar f i l e h a s h Spacebar - a Spacebar Alt+h Backspace Backspace a Tab Alt+h Ctrl+a Backspace f i l e h a s h Spacebar - a Tab Alt+h
    
    ### Exception
    
    Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
       at CallSite.Target(Closure, CallSite, Object)
       at Microsoft.PowerShell.PSConsoleReadLine.WriteParameterHelp(Object helpContent)
       at Microsoft.PowerShell.PSConsoleReadLine.WriteDynamicHelpContent(String commandName, String parameterName, Boolean isFullHelp)
       at Microsoft.PowerShell.PSConsoleReadLine.DynamicHelpImpl(Boolean isFullHelp)
       at Microsoft.PowerShell.PSConsoleReadLine.ShowParameterHelp(Nullable`1 key, Object arg)
       at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
       at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

    Interestingly, PSReadlineKeyHandler -Chord + <alt+h> returns No help content available. Please use Update-Help to download the latest help content.

    Below is the output from Dongbo using Get-FileHash

    PS> $v | gm
       TypeName: MamlCommandHelpInfo#parameter
    
    Name           MemberType   Definition
    ----           ----------   ----------
    Equals         Method       bool Equals(System.Object obj)
    GetHashCode    Method       int GetHashCode()
    GetType        Method       type GetType()
    ToString       Method       string ToString()
    aliases        NoteProperty string aliases=none
    defaultValue   NoteProperty System.String defaultValue=SHA256
    description    NoteProperty psobject[] description=System.Management.Automation.PSObject[]
    globbing       NoteProperty string globbing=false
    name           NoteProperty System.String name=Algorithm
    parameterValue NoteProperty System.String parameterValue=System.String
    pipelineInput  NoteProperty string pipelineInput=False
    position       NoteProperty string position=1
    required       NoteProperty string required=false
    type           NoteProperty MamlCommandHelpInfo#type type=@{uri=; name=System.String}
    variableLength NoteProperty string variableLength=true
    PS> $null -eq $v.type
    False
    PS> $v | fl
    
    name           : Algorithm
    defaultValue   : SHA256
    type           : @{uri=; name=System.String}
    parameterValue : System.String
    description    : {@{Text=Specifies the cryptographic hash function to use for computing the hash value of the contents of the specified file or stream. A cryptographic hash function has the property that it is infeasible to find two different files with the same hash value. Hash functions are commonly used with digital signatures and for data integrity. The acceptable values for this parameter are:
                     }, @{Text=- SHA1
                     }, @{Text=- SHA256
                     }, @{Text=- SHA384
                     }…}
    required       : false
    variableLength : true
    globbing       : false
    pipelineInput  : False
    position       : 1
    aliases        : none

    Below is the output using FileHash. Notice the TypeName is different and $v.Type is $null.

    PS>
    
       TypeName: HelpInfoShort
    
    Name          MemberType   Definition
    ----          ----------   ----------
    Equals        Method       bool Equals(System.Object obj)
    GetHashCode   Method       int GetHashCode()
    GetType       Method       type GetType()
    ToString      Method       string ToString()
    alertSet      NoteProperty MamlCommandHelpInfo#alertSet alertSet=@{alert=System.Management.Automation.PSObject[]}
    Category      NoteProperty string Category=Cmdlet
    Component     NoteProperty object Component=null
    description   NoteProperty psobject[] description=System.Management.Automation.PSObject[]
    details       NoteProperty MamlCommandHelpInfo#details details=@{name=Get-FileHash; verb=Get; description=System.Management.Automation.PSObject[]; noun=FileHash}
    examples      NoteProperty MamlCommandHelpInfo#examples examples=@{example=System.Management.Automation.PSObject[]}
    Functionality NoteProperty object Functionality=null
    inputTypes    NoteProperty MamlCommandHelpInfo#inputTypes inputTypes=@{inputType=@{type=@{name=System.String}; description=System.Management.Automation.PSObject[]}}
    ModuleName    NoteProperty string ModuleName=Microsoft.PowerShell.Utility
    Name          NoteProperty string Name=Get-FileHash
    parameters    NoteProperty MamlCommandHelpInfo#parameters parameters=@{parameter=System.Management.Automation.PSObject[]}
    PSSnapIn      NoteProperty object PSSnapIn=null
    relatedLinks  NoteProperty MamlCommandHelpInfo#relatedLinks relatedLinks=@{navigationLink=System.Management.Automation.PSObject[]}
    returnValues  NoteProperty MamlCommandHelpInfo#returnValues returnValues=@{returnValue=@{type=@{name=Microsoft.PowerShell.Utility.FileHash}; description=System.Management.Automation.PSObject[]}}
    Role          NoteProperty object Role=null
    Synopsis      NoteProperty string Synopsis=Computes the hash value for a file by using a specified hash algorithm.
    syntax        NoteProperty MamlCommandHelpInfo#syntax syntax=@{syntaxItem=System.Management.Automation.PSObject[]}
    xmlns:command NoteProperty string xmlns:command=http://schemas.microsoft.com/maml/dev/command/2004/10
    xmlns:dev     NoteProperty string xmlns:dev=http://schemas.microsoft.com/maml/dev/2004/10
    xmlns:maml    NoteProperty string xmlns:maml=http://schemas.microsoft.com/maml/2004/10
    xmlns:MSHelp  NoteProperty string xmlns:MSHelp=http://msdn.microsoft.com/mshelp
    PS> $null -eq $v.type
    True
    PS> $v | fl
    
    alertSet      : @{alert=System.Management.Automation.PSObject[]}
    inputTypes    : @{inputType=@{type=@{name=System.String}; description=System.Management.Automation.PSObject[]}}
    examples      : @{example=System.Management.Automation.PSObject[]}
    syntax        : @{syntaxItem=System.Management.Automation.PSObject[]}
    returnValues  : @{returnValue=@{type=@{name=Microsoft.PowerShell.Utility.FileHash}; description=System.Management.Automation.PSObject[]}}
    details       : @{name=Get-FileHash; verb=Get; description=System.Management.Automation.PSObject[]; noun=FileHash}
    parameters    : @{parameter=System.Management.Automation.PSObject[]}
    relatedLinks  : @{navigationLink=System.Management.Automation.PSObject[]}
    description   : {@{Text=The `Get-FileHash` cmdlet computes the hash value for a file by using a specified hash algorithm. A hash value is a unique value that corresponds to the content of the file. Rather than identifying the contents of a file by its file name, extension, or other designation, a hash assigns a unique value to the contents of a file. File names and extensions can be changed without altering the content of the file, and without changing the hash value. Similarly, the file's content can be changed without changing the name or extension. However, changing even a single character in the contents of a file changes the hash value of the file.
                    }, @{Text=The purpose of hash values is to provide a cryptographically-secure way to verify that the contents of a file have not been changed. While some hash algorithms, including MD5 and SHA1, are no longer considered secure against attack, the goal of a secure hash algorithm is to render it impossible to change the contents of a file -- either by accident, or by malicious or unauthorized attempt -- and maintain the same hash value. You can also use hash values to determine if two different files have exactly the same content. If the hash values of two files are identical, the contents of the files are also identical.
                    }, @{Text=By default, the `Get-FileHash` cmdlet uses the SHA256 algorithm, although any hash algorithm that is supported by the target operating system can be used.}}
    xmlns:maml    : http://schemas.microsoft.com/maml/2004/10
    xmlns:command : http://schemas.microsoft.com/maml/dev/command/2004/10
    xmlns:dev     : http://schemas.microsoft.com/maml/dev/2004/10
    xmlns:MSHelp  : http://msdn.microsoft.com/mshelp
    Name          : Get-FileHash
    Category      : Cmdlet
    Synopsis      : Computes the hash value for a file by using a specified hash algorithm.
    Component     : 
    Role          : 
    Functionality : 
    PSSnapIn      : 
    ModuleName    : Microsoft.PowerShell.Utility

    Using PSReadLineKeyHandler as the cmdlet, has the same output as FileHash. It does not throw the error though. Alias -Name does fail in the same way too.

  6. daxian-dbw commented on Oct 22, 2025

    @daxian-dbw
    Member

    Thanks all for the help!
    This is a duplicate issue of #4960 and is now fixed with the PR #4971.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions