Skip to content

Read-SpectreConfirm -Message 'Proceed?' suddenly gave error Cannot process argument transformation on parameter 'Color'. Object reference not set to an instance of an object. #122

@o-l-a-v

Description

@o-l-a-v

I don't know how I got into this state. I first ran with $env:IgnoreSpectreEncoding = $true a few times, and it worked. Then it stopped working and gave mentioned error. I then tried enabling UTF8 and $env:IgnoreSpectreEncoding = $false, but it did not solve it. Restarting the PowerShell sessions solves it.

Env info:

  • Windows 11 24H2 x64
  • PowerShell v7.5.1 x64
  • PwshSpectreConsole v2.3.0
  • VSCode with vscode-powershell v2025.0.0
  • oh-my-posh 26.2.0

Some more error details:

Message                     : Cannot process argument transformation on parameter 'Color'. Object reference not set to an instance of an object.
ParameterName               : Color
ParameterType               : Spectre.Console.Color
TypeSpecified               : Spectre.Console.Color
ErrorId                     : ParameterArgumentTransformationError
Line                        : 1
Offset                      : 1
CommandInvocation           : System.Management.Automation.InvocationInfo
ErrorRecord                 : Cannot process argument transformation on parameter 'Color'. Object reference not set to an instance of an object.
WasThrownFromThrowStatement : False
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
Data                        : {[System.Management.Automation.Interpreter.InterpretedFrameInfo, System.Management.Automation.Interpreter.InterpretedFrameInfo[]]}
InnerException              : System.Management.Automation.RuntimeException: Object reference not set to an instance of an object.
                               ---> System.NullReferenceException: Object reference not set to an instance of an object.
                                 at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input,   
                              Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine,     
                              Object[] args)
                                 at System.Management.Automation.ScriptBlock.InvokeAsMemberFunctionT[T](Object instance, Object[] args)
                                 at System.Management.Automation.Internal.ScriptBlockMemberMethodWrapper.InvokeHelperT[T](Object instance, Object sessionStateInternal, Object[] args)
                                 at ColorTransformationAttribute.TransformItem(Object inputData)
                                 at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 --- End of inner exception stack trace ---
                                 at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
                                 at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
                                 at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
                                 at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2
                              functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe,       
                              InvocationInfo invocationInfo, Object[] args)
                                 at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input,   
                              Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine,     
                              Object[] args)
                                 at System.Management.Automation.ScriptBlock.InvokeAsMemberFunctionT[T](Object instance, Object[] args)
                                 at System.Management.Automation.Internal.ScriptBlockMemberMethodWrapper.InvokeHelperT[T](Object instance, Object sessionStateInternal, Object[] args)
                                 at ColorTransformationAttribute.Transform(EngineIntrinsics engine, Object inputData)
                                 at System.Management.Automation.ArgumentTransformationAttribute.TransformInternal(EngineIntrinsics engineIntrinsics, Object inputData, Boolean
                              trackDataInputSource)
                                 at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata,
                              ParameterBindingFlags flags)
HelpLink                    : 
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.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
                                 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 Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings
                              invocationSettings) in C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 76
                                 at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in
                              C:\__w\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 108

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions