Repository navigation
Update-Help not working with https? #9316
Description
Steps to reproduce
I have created updatable help system according to docs.microsoft.com pages
You may see the module here. Module info and content files are inside cab directory.
It is working fine in Windows PowerShell, but not in PowerShell Core v.6.2
Update-Help -Module InstallModuleFromGit -Verbose -ForceExpected behavior
This is the output from Windows PowerShell session.
VERBOSE: Your connection has been redirected to the following URI: "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/iricigor/InstallModuleFromGit/raw/master/cab/"
VERBOSE: Performing the operation "Update-Help" on target "InstallModuleFromGit, Current Version: 0.0.0.0, Available Version: 1.0.0.0, UICulture:
en-US".
VERBOSE: InstallModuleFromGit: Updated W:\PowerShell\GitHub\InstallModuleFromGit\en-US\InstallGitModule-help.xml. Culture en-US Version 1.0.0.0
VERBOSE: InstallModuleFromGit: Updated W:\PowerShell\GitHub\InstallModuleFromGit\en-US\InstallModuleFromGit-help.xml. Culture en-US Version 1.0.0.0
Actual behavior
And this is the output from PowerShell Core.
VERBOSE: Your connection has been redirected to the following URI: "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/iricigor/InstallModuleFromGit/raw/master/cab/"
VERBOSE: Performing the operation "Update-Help" on target "InstallModuleFromGit, Current Version: 0.0.0.0, Available Version: 1.0.0.0, UICulture: en-US".
VERBOSE: Your connection has been redirected to the following URI: "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/iricigor/InstallModuleFromGit/raw/master/cab/"
VERBOSE: Performing the operation "Update-Help" on target "InstallModuleFromGit, Current Version: 0.0.0.0, Available Version: 1.0.0.0, UICulture: en-US".
update-help : Failed to update Help for the module(s) 'InstallModuleFromGit' with UI culture(s) {en-US} : Help content cannot be found. Make sure the server is available and the help content location is properly defined in the HelpInfo XML.
At line:1 char:1
+ update-help -Module InstallModuleFromGit -Verbose -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [Update-Help], Exception
+ FullyQualifiedErrorId : HelpContentNotFound,Microsoft.PowerShell.Commands.UpdateHelpCommand
Environment data
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Comment 1
I have compared my setup and PowerShell built-in modules setup and the only difference I noticed was https (my setup) vs. http protocol (PowerShell modules). So, I tried to use http to prove it in new branch, but I could not give proof as GitHub seems to redirect download requests, as visible in the PS Core output above. Notice that first redirect points to http, and 2nd one to https and then it fails.
Comment 2
I have tried also to simulate really missing files and in that case I receive one more error before the one above. This new error says:
Response status code does not indicate success: 404 (Not Found)
Comment 3
Even if this turns out to be my setup problem, I think such generic error messages should be improved. The error HelpContentNotFound was being thrown if anything fails, without real control if content is found or not. Also, at least it my experience it looks like InnerException is just dismissed, as I was not able to see it in any error.
Activity
iSazonov commentedon Jan 30, 2020
Do you see the issue with PowerShell 7.0?
iricigor commentedon Jul 15, 2020
Hi Ilya (@iSazonov) , Sorry for delayed response.
Yes, the same behavior can be observed in PowerShell 7.0.2, the error is still
HelpContentNotFound,Microsoft.PowerShell.Commands.UpdateHelpCommandIt is failing also on WSL
Just for reference, here is successful output from Windows PowerShell 5.1
iSazonov commentedon Jul 15, 2020
/cc Sean Wheeler (@sdwheeler) Have you any thoughts about the issue?
iricigor commentedon Jul 15, 2020
Sorry, I just noticed that error message is not the same! Error category is the same, but descrription is now updated. There is this additional line:
However, running update with that parameter is not helping. It is visible from original command that it is trying already to download
en-UShelp.That error description points to this piece of code.
If I specify some unsupported culture, I will get proper message.
Note that message now says
The specified culture is not supportedinstead ofHelp content cannot be foundIf I use the same files as published, but from local folder,
Update-Helpis successful.iricigor commentedon Jul 15, 2020
So, I seems to have found the root cause.
I am using this url for help
https://github.com/iricigor/InstallModuleFromGit/raw/master/cab/which seems to be OKBut, if I run it like this, it shows the problem:
So, the problem is this piece of code. It is not allowing redirects.
Conclusion and Final Question
Updates on my side is simple, but this is different behavior in Windows PowerShell and PowerShell 7. Windows PowerShell is allowing redirects during
Update-Helpcommand, while PowerShell 7 is not allowing them. Was this intentional or should it be fixed?iSazonov commentedon Jul 15, 2020
Igor (@iricigor) The code you referenced comes from Windows PowerShell.
/cc Aditya Patwardhan (@adityapatwardhan) for conclusion.
sdwheeler commentedon Jul 15, 2020
I think the real problem is GitHub. They don't allow raw access to the files in the repo they way Update-Help expects to get them. You might have better results if you published the help files (xml/cab/zip) in the release assests. Then GitHub provides a direct download URL
https://github.com/iricigor/releases/download/InstallModuleFromGit/<release-tag>/.iricigor commentedon Jul 15, 2020
Sean Wheeler (@sdwheeler) I managed to update my module to use direct (not redirected) url for help files, and I am not getting
HelpContentNotFounderror anymore.Ilya (@iSazonov) Yeap, I figured out that mentioned code comes from monad times, so I am not sure why it works in Windows PowerShell. I tried to recompile DownloadHelpContentHttpClient code on my machine, and it is failing on this line a few lines later in the code
Variable
responsegets status code 301 and it fails. If recompiled withhandler.AllowAutoRedirect = true;it returns success status.iSazonov commentedon Jul 16, 2020
Igor (@iricigor) You could compile a debug build and use debugger to find a place where the fix could be. This makes sense only if Aditya Patwardhan (@adityapatwardhan) confirms.
adityapatwardhan commentedon Jul 16, 2020
I am sorry, working on a release now. I can only have a look at this after the release.
iricigor commentedon Jul 16, 2020
Aditya Patwardhan (@adityapatwardhan) Take your time, nothing urgent here. I will just summarize the above here.
Summary
Command
Update-Helpbehaves differently in Windows PowerShell and PowerShell Core / PowerShell 7. If target url is redirected, Windows PowerShell follows the url and returns success. In case of pwsh, it returns an errorHelpContentNotFound.Root cause
In current PowerShell, the code explicitly disallows redirects. It can be easily updated, if needed. The mentioned code is coming from Windows PowerShell time and its not modified during PowerShell OSS era.
Questions
iSazonov commentedon Jul 16, 2020
/cc Travis Plunk (@TravisEz13)
sdwheeler commentedon Jul 16, 2020
Redirects are required because we use our FWLink redirection service for these URLs.
TravisEz13 commentedon Aug 19, 2020
Redirection is allowed for non-executable content (for Microsoft services HTTPS is required)
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.