You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DefaultCommandPrefix from Module PSD ignored after recent patch #25419
Import a PowerShell module with a DefaultCommandPrefix set in the .psd file
As an example, use my module totkeks.GitManagement from PowerShell gallery
Run command Set-GitBaseDirectory
Source of the error from this PR #20409 (comment), where it is not checking for String.IsNullOrEmpty() anymore, instead using just null coalescing ??, which doesn't include String.Empty.
Expected behavior
* Commands are prefixed with the defined prefix, e.g. `Git`, and are working / found in the current scope
Actual behavior
* Command not found, because the prefix was overwritten with an empty string
Error details
Environment data
$PSVersionTable
Name Value
---------
PSVersion 7.6.0-preview.4
PSEdition Core
GitCommitId 7.6.0-preview.4
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I think we are in luck. As far as I can tell, all other references to the prefix with a default value uses IsNullOrEmpty so a simple fix would be to just change the default value to a null.
It's a very complicated code area for sure. TBH I don't see myself investing the time and effort to dig further into this so unless someone else steps up we can also just revert the change.
Activity
iSazonov commentedon Apr 22, 2025
Possible regression from #20409. It seems we skipped that BasePrefix is initialized with string.Empty.
https://github.com/MartinGC94/PowerShell/blob/e18db00c8004f8b8639c9b65d922bb96e42e2ba9/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs#L120
iSazonov commentedon Apr 22, 2025
/cc MartinGC94
MartinGC94 commentedon Apr 23, 2025
I think we are in luck. As far as I can tell, all other references to the prefix with a default value uses
IsNullOrEmptyso a simple fix would be to just change the default value to a null.iSazonov commentedon Apr 24, 2025
I'm just afraid that there are too few tests to avoid regression. They should be added.
MartinGC94 commentedon Apr 24, 2025
It's a very complicated code area for sure. TBH I don't see myself investing the time and effort to dig further into this so unless someone else steps up we can also just revert the change.
iSazonov commentedon Apr 25, 2025
MartinGC94 Please pull the revert PR.
microsoft-github-policy-service commentedon Apr 28, 2025
📣 Hey @Norman Dankert (@totkeks), how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback