Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error New-PSDrive : 404: Not Found when trying to mount account drive #455

Closed
FH-Inway opened this issue Feb 26, 2022 · 6 comments · Fixed by #456
Closed

Error New-PSDrive : 404: Not Found when trying to mount account drive #455

FH-Inway opened this issue Feb 26, 2022 · 6 comments · Fixed by #456
Assignees
Labels
bug when a bug has been identified or filed

Comments

@FH-Inway
Copy link

Steps to reproduce

Set-VSTeamAccount -Account MyAccount -PersonalAccessToken mytoken -Drive MyAccountDrive
New-PSDrive -Name MyAccountDrive -PSProvider SHiPS -Root 'VSTeam#vsteam_lib.Provider.Account' -Description https://dev.azure.com/MyAccount

Expected behavior

I expected that a drive for my account is mounted as described in https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/about/about_vsteam_provider.help/

Actual behavior?

I had the following actual outcome:

VERBOSE: Performing the operation "New drive" on target "Name: vsteam Provider: SHiPS\SHiPS Root:
VSTeam#vsteam_lib.Provider.Account".
VERBOSE: import-module VSTeam; get-module VSTeam -verbose
VERBOSE: C:\Program Files\WindowsPowerShell\Modules\VSTeam\7.6.0\VSTeam.psd1
VERBOSE: using module 'C:\Program Files\WindowsPowerShell\Modules\VSTeam\7.6.0\VSTeam.psd1'; $mod=get-module VSTeam;
&($mod){[vsteam_lib.Provider.Account]::new('vsteam_lib.Provider.Account')}
New-PSDrive : 404: Not Found
At line:1 char:1
+ New-PSDrive -Name vsteam -PSProvider SHiPS -Root 'VSTeam#vsteam_lib.P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [New-PSDrive], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.NewPSDriveCommand

From the TargetObject property of the Get-Error cmdlet, it seems that the issue is a call to https://raw.githubusercontent.com/MethodsAndPractices/vsteam/topic/addModuleLoadingNotifications/.github/moduleMessages.json

This seems to be a recent addition, see 682186d

Information from Get-Error:

Exception             :
    Type       : Microsoft.PowerShell.Commands.HttpResponseException
    Response   : StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content:
System.Net.Http.HttpConnectionResponseContent, Headers:
                 {
                 Connection: keep-alive
                 Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
                 Strict-Transport-Security: max-age=31536000
                 X-Content-Type-Options: nosniff
                 X-Frame-Options: DENY
                 X-XSS-Protection: 1; mode=block
                 X-GitHub-Request-Id: CD5E:EE9C:64B123:6E6276:621A36C5
                 Accept-Ranges: bytes
                 Date: Sat, 26 Feb 2022 14:19:39 GMT
                 Via: 1.1 varnish
                 X-Served-By: cache-hhn4082-HHN
                 X-Cache: HIT
                 X-Cache-Hits: 1
                 X-Timer: S1645885180.891985,VS0,VE1
                 Vary: Authorization,Accept-Encoding,Origin
                 Access-Control-Allow-Origin: *
                 X-Fastly-Request-ID: c963522aeee3a26659e150732cb7fca0ecf9b081
                 Source-Age: 54
                 Content-Length: 14
                 Content-Type: text/plain; charset=utf-8
                 Expires: Sat, 26 Feb 2022 14:24:39 GMT
                 }
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation,
Version=7.2.1.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message    : Response status code does not indicate success: 404 (Not Found).
    Source     : System.Management.Automation
    HResult    : -2146233088
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject          : Method: GET, RequestUri: 'https://raw.githubusercontent.com/MethodsAndPractices/vsteam/topic/ad
dModuleLoadingNotifications/.github/moduleMessages.json', Version: 1.1, Content: System.Net.Http.StringContent,
Headers:
                        {
                        User-Agent: Mozilla/5.0
                        User-Agent: (Windows NT 10.0; Microsoft Windows 10.0.19044; de-DE)
                        User-Agent: PowerShell/7.2.1
                        Content-Length: 0
                        }
CategoryInfo          : InvalidOperation: (Method: GET, Reques…ontent-Length: 0
                        }:HttpRequestMessage) [New-PSDrive], HttpResponseException
FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.NewPSDriveCommand
ErrorDetails          : 404: Not Found
InvocationInfo        :
    MyCommand        : New-PSDrive
    ScriptLineNumber : 2
    OffsetInLine     : 1
    HistoryId        : 13
    Line             : New-PSDrive -Name MyAccount -PSProvider SHiPS -Root 'VSTeam#vsteam_lib.Provider.Account'
-Description https://dev.azure.com/MyAccount
    PositionMessage  : At line:2 char:1
                       + New-PSDrive -Name MyAccount -PSProvider SHiPS -Root 'VSTeam#vst …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : New-PSDrive
    CommandOrigin    : Internal
ScriptStackTrace      : at _showModuleLoadingMessages<Process>,
C:\Program Files\WindowsPowerShell\Modules\VSTeam\7.6.0\vsteam.functions.ps1: line 1067
                        at <ScriptBlock>,
C:\Program Files\WindowsPowerShell\Modules\VSTeam\7.6.0\VSTeam.psm1: line 26
PipelineIterationInfo :

On Which OS have you tried it?

Windows

What was your server version?

Azure DevOps Services

Other server version

No response

Log output of used API

_getApiVersion : Cannot validate argument on parameter 'Service'. The argument "Version" does not belong to the set "Bu
ild,Release,Core,Git,DistributedTask,DistributedTaskReleased,VariableGroups,Tfvc,Packaging,MemberEntitlementManagement,
ExtensionsManagement,ServiceEndpoints,Graph,TaskGroups,Policy,Processes,HierarchyQuery,Pipelines,Billing,Wiki,WorkItemT
racking" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
At C:\Program Files\WindowsPowerShell\Modules\VSTeam\7.6.0\vsteam.functions.ps1:3594 char:57
+          Version                     = $(_getApiVersion Version)
+                                                         ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [_getApiVersion], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,_getApiVersion



Billing                     : 5.1-preview.1
Build                       : 5.1
Core                        : 5.1
DistributedTask             : 6.0-preview
DistributedTaskReleased     : 5.1
ExtensionsManagement        : 6.0-preview
Git                         : 5.1
Graph                       : 6.0-preview
HierarchyQuery              : 5.1-preview
MemberEntitlementManagement : 6.0-preview
Packaging                   : 6.0-preview
Pipelines                   : 5.1-preview
Policy                      : 5.1
Processes                   : 6.0-preview
Release                     : 5.1
ServiceEndpoints            : 5.0-preview
TaskGroups                  : 6.0-preview
Tfvc                        : 5.1
VariableGroups              : 5.1-preview.1
Version                     :
Wiki                        : 6.0
WorkItemTracking            : 6.0-preview.1

Log output of $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.4583
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.4583
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Name                           Value
----                           -----
PSVersion                      5.1.19041.1320
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1320
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@FH-Inway FH-Inway added the bug when a bug has been identified or filed label Feb 26, 2022
@FH-Inway
Copy link
Author

moduleMessages.json is referenced in

$moduleMessagesRes = (Invoke-RestMethod "https://raw.githubusercontent.com/MethodsAndPractices/vsteam/topic/addModuleLoadingNotifications/.github/moduleMessages.json")

The correct link should probably be https://raw.githubusercontent.com/MethodsAndPractices/vsteam/trunk/.github/moduleMessages.json

@FH-Inway
Copy link
Author

Found a work around by enabling the environment variable VSTEAM_NO_MODULE_MESSAGES:

$env:VSTEAM_NO_MODULE_MESSAGES = $true

After that, the New-PSDrive cmdlet worked and the account was mounted as a drive.

@FH-Inway FH-Inway changed the title Error new-PSDrive : 404: Not Found when trying to mount account drive Error New-PSDrive : 404: Not Found when trying to mount account drive Feb 26, 2022
@SebastianSchuetze
Copy link
Collaborator

Thanks. That is a new feature and you actually used a valid variable to deactivate it.

It is just not documented. But the exception is not supposed to happen. I will look into it.

@SebastianSchuetze
Copy link
Collaborator

@FH-Inway would you be so kind to check whether #456 works for you? If no problems come up for you I would merge it.

@FH-Inway
Copy link
Author

FH-Inway commented Mar 5, 2022

@SebastianSchuetze I tried to do a build to test the changes, but ran into issues during the build. The changes look otherwise good to me, so I think you can go ahead with the merge. In the worst case, the fixed url still does not work for some reason, which can be adressed with the workaround.

@FH-Inway
Copy link
Author

FH-Inway commented Mar 5, 2022

My curiosity got the better of me and I looked into the errors I got from the build script. Turns out I was using the wrong PowerShell version (5.1 instead of 7) and missing the .NET Core 3.1 SDK. You are probably thinking "duh, of course you need those" and I'm sure that if I wasn't a total newbie at this module, it would probably be obvious to me, too. Still, you might want to consider adding those requirements to the build information.

Long story short, I was able to build branch SebastianSchuetze/issue455 and able to verify that it fixes the issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug when a bug has been identified or filed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants