bagetter/BaGetter

push falls back to v2

Closed this issue · 3 comments

Describe the bug

Calling dotnet nuget push package.nupkg -s http://mywebsite.com/v3/index.json -k "myapikey" tries to push to `http://mysite/api/v2/package/'

> dotnet nuget push MyPackage.nupkg -s http://mywebsite.com/v3/index.json -k "MYAPIKEY"
warn : You are running the 'push' operation with an 'HTTP' source, 'http://mywebsite.com/v3/index.json'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
Pushing MyPackage.nupkg to 'http://mywebsite.com/api/v2/package'...
warn : You are running the 'push' operation with an 'HTTP' source, 'http://mywebsite.com/api/v2/package/'. Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.
  PUT http://mywebsite.com/api/v2/package/
  MethodNotAllowed http://mywebsite.com/api/v2/package/ 148ms
error: Response status code does not indicate success: 405 (Method Not Allowed).

Usage: dotnet nuget push [arguments] [options]

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of BaGetter '1.0.4'
  2. Using dotnet 8.0.200
  3. dotnet nuget push package.nupkg -s http://mywebsite.com/v3/index.json -k "myapikey"

Expected behavior

I'd expect the package to upload.

Additional context

I changed the URL from my actual URL to mywebsite.com (this is not my actual website)

Logs

info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (15ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (0ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT COUNT(*) FROM "sqlite_master" WHERE "name" = '__EFMigrationsHistory' AND "type" = 'table';
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      SELECT "MigrationId", "ProductVersion"
      FROM "__EFMigrationsHistory"
      ORDER BY "MigrationId";
info: Microsoft.EntityFrameworkCore.Migrations[20405]
      No migrations were applied. The database is already up to date.
warn: Microsoft.AspNetCore.DataProtection.Repositories.EphemeralXmlRepository[50]
      Using an in-memory repository. Keys will not be persisted to storage.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[59]
      Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58]
      Creating key {0991a841-8d5c-44b2-a895-6958edb09647} with creation date 2024-02-29 22:12:54Z, activation date 2024-02-29 22:12:54Z, and expiration date 2024-05-29 22:12:54Z.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {0991a841-8d5c-44b2-a895-6958edb09647} may be persisted to storage in unencrypted form.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\inetpub\bagetter
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://mywebsite.com/v3/index.json - - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'BaGetter.Web.ServiceIndexController.GetAsync (BaGetter.Web)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
      Route matched with {action = "Get", controller = "ServiceIndex", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[BaGetter.Protocol.Models.ServiceIndexResponse] GetAsync(System.Threading.CancellationToken) on controller BaGetter.Web.ServiceIndexController (BaGetter.Web).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
      Executing ObjectResult, writing value of type 'BaGetter.Protocol.Models.ServiceIndexResponse'.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105]
      Executed action BaGetter.Web.ServiceIndexController.GetAsync (BaGetter.Web) in 122.5868ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'BaGetter.Web.ServiceIndexController.GetAsync (BaGetter.Web)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://mywebsite.com/v3/index.json - 200 - application/json;+charset=utf-8 224.9759ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://mywebsite.com/upload - - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '/Upload'
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[103]
      Route matched with {page = "/Upload", action = "", controller = ""}. Executing page /Upload
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[107]
      Executing an implicit handler method - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[109]
      Executed an implicit handler method, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult.
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[104]
      Executed page /Upload in 117.92ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/Upload'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://mywebsite.com/upload - 200 - text/html;+charset=utf-8 139.2168ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://mywebsite.com/v3/index.json - - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'BaGetter.Web.ServiceIndexController.GetAsync (BaGetter.Web)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[102]
      Route matched with {action = "Get", controller = "ServiceIndex", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[BaGetter.Protocol.Models.ServiceIndexResponse] GetAsync(System.Threading.CancellationToken) on controller BaGetter.Web.ServiceIndexController (BaGetter.Web).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor[1]
      Executing ObjectResult, writing value of type 'BaGetter.Protocol.Models.ServiceIndexResponse'.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[105]
      Executed action BaGetter.Web.ServiceIndexController.GetAsync (BaGetter.Web) in 4.5307ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint 'BaGetter.Web.ServiceIndexController.GetAsync (BaGetter.Web)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://mywebsite.com/v3/index.json - 200 - application/json;+charset=utf-8 9.9623ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET http://mywebsite.com/ - - -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '/Index'
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[103]
      Route matched with {page = "/Index", action = "", controller = ""}. Executing page /Index
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[105]
      Executing handler method BaGetter.Web.IndexModel.OnGetAsync - ModelState is Valid
info: Microsoft.EntityFrameworkCore.Database.Command[20101]
      Executed DbCommand (6ms) [Parameters=[@__p_1='?' (DbType = Int32), @__p_0='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30']
      SELECT "p"."Key", "p"."Authors", "p"."Description", "p"."Downloads", "p"."HasEmbeddedIcon", "p"."HasReadme", "p"."IconUrl", "p"."Id", "p"."IsPrerelease", "p"."Language", "p"."LicenseUrl", "p"."Listed", "p"."MinClientVersion", "p"."Version", "p"."OriginalVersion", "p"."ProjectUrl", "p"."Published", "p"."ReleaseNotes", "p"."RepositoryType", "p"."RepositoryUrl", "p"."RequireLicenseAcceptance", "p"."RowVersion", "p"."SemVerLevel", "p"."Summary", "p"."Tags", "p"."Title"
      FROM "Packages" AS "p"
      WHERE "p"."Id" IN (
          SELECT "t"."Id"
          FROM (
              SELECT DISTINCT "p0"."Id"
              FROM "Packages" AS "p0"
              WHERE "p0"."Listed"
          ) AS "t"
          ORDER BY "t"."Id"
          LIMIT @__p_1 OFFSET @__p_0
      ) AND "p"."Listed"
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[108]
      Executed handler method OnGetAsync, returned result Microsoft.AspNetCore.Mvc.RazorPages.PageResult.
info: Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionInvoker[104]
      Executed page /Index in 535.955ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/Index'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://mywebsite.com/ - 200 - text/html;+charset=utf-8 554.9765ms
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...

GET http://mywebsite.com/v3/index.json

{
    "version": "3.0.0",
    "resources": [
        {
            "@id": "http://mywebsite.com/api/v2/package",
            "@type": "PackagePublish/2.0.0"
        },
        {
            "@id": "http://mywebsite.com/api/v2/symbol",
            "@type": "SymbolPackagePublish/4.9.0"
        },
        {
            "@id": "http://mywebsite.com/v3/search",
            "@type": "SearchQueryService"
        },
        {
            "@id": "http://mywebsite.com/v3/search",
            "@type": "SearchQueryService/3.0.0-beta"
        },
        {
            "@id": "http://mywebsite.com/v3/search",
            "@type": "SearchQueryService/3.0.0-rc"
        },
        {
            "@id": "http://mywebsite.com/v3/registration",
            "@type": "RegistrationsBaseUrl"
        },
        {
            "@id": "http://mywebsite.com/v3/registration",
            "@type": "RegistrationsBaseUrl/3.0.0-rc"
        },
        {
            "@id": "http://mywebsite.com/v3/registration",
            "@type": "RegistrationsBaseUrl/3.0.0-beta"
        },
        {
            "@id": "http://mywebsite.com/v3/package",
            "@type": "PackageBaseAddress/3.0.0"
        },
        {
            "@id": "http://mywebsite.com/v3/autocomplete",
            "@type": "SearchAutocompleteService"
        },
        {
            "@id": "http://mywebsite.com/v3/autocomplete",
            "@type": "SearchAutocompleteService/3.0.0-rc"
        },
        {
            "@id": "http://mywebsite.com/v3/autocomplete",
            "@type": "SearchAutocompleteService/3.0.0-beta"
        }
    ]
}

PUT http://mywebsite.com/api/v2/package/ HTTP/1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>IIS 10.0 Detailed Error - 405.0 - Method Not Allowed</title> 
<style type="text/css"> 
<!-- 
body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;} 
code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} 
.config_source code{font-size:.8em;color:#000000;} 
pre{margin:0;font-size:1.4em;word-wrap:break-word;} 
ul,ol{margin:10px 0 10px 5px;} 
ul.first,ol.first{margin-top:5px;} 
fieldset{padding:0 15px 10px 15px;word-break:break-all;} 
.summary-container fieldset{padding-bottom:5px;margin-top:4px;} 
legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} 
legend{color:#333333;;margin:4px 0 8px -12px;_margin-top:0px; 
font-weight:bold;font-size:1em;} 
a:link,a:visited{color:#007EFF;font-weight:bold;} 
a:hover{text-decoration:none;} 
h1{font-size:2.4em;margin:0;color:#FFF;} 
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.4em;margin:10px 0 0 0;color:#CC0000;} 
h4{font-size:1.2em;margin:10px 0 5px 0; 
}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS",Verdana,sans-serif; 
 color:#FFF;background-color:#5C87B2; 
}#content{margin:0 0 0 2%;position:relative;} 
.summary-container,.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;} 
.content-container p{margin:0 0 10px 0; 
}#details-left{width:35%;float:left;margin-right:2%; 
}#details-right{width:63%;float:left;overflow:hidden; 
}#server_version{width:96%;_height:1px;min-height:1px;margin:0 0 5px 0;padding:11px 2% 8px 2%;color:#FFFFFF; 
 background-color:#5A7FA5;border-bottom:1px solid #C1CFDD;border-top:1px solid #4A6C8E;font-weight:normal; 
 font-size:1em;color:#FFF;text-align:right; 
}#server_version p{margin:5px 0;} 
table{margin:4px 0 4px 0;width:100%;border:none;} 
td,th{vertical-align:top;padding:3px 0;text-align:left;font-weight:normal;border:none;} 
th{width:30%;text-align:right;padding-right:2%;font-weight:bold;} 
thead th{background-color:#ebebeb;width:25%; 
}#details-right th{width:20%;} 
table tr.alt td,table tr.alt th{} 
.highlight-code{color:#CC0000;font-weight:bold;font-style:italic;} 
.clear{clear:both;} 
.preferred{padding:0 5px 2px 5px;font-weight:normal;background:#006633;color:#FFF;font-size:.8em;} 
--> 
</style> 
 
</head> 
<body> 
<div id="content"> 
<div class="content-container"> 
  <h3>HTTP Error 405.0 - Method Not Allowed</h3> 
  <h4>The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.</h4> 
</div> 
<div class="content-container"> 
 <fieldset><h4>Most likely causes:</h4> 
  <ul> 	<li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li> 	<li>A request was sent to the server that contained an invalid HTTP verb.</li> 	<li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li> 	<li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul> 
 </fieldset> 
</div> 
<div class="content-container"> 
 <fieldset><h4>Things you can try:</h4> 
  <ul> 	<li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li> 	<li>Check the IIS log file to see which verb is not allowed for the request.</li> 	<li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>. </li> </ul> 
 </fieldset> 
</div> 
 
<div class="content-container"> 
 <fieldset><h4>Detailed Error Information:</h4> 
  <div id="details-left"> 
   <table border="0" cellpadding="0" cellspacing="0"> 
    <tr class="alt"><th>Module</th><td>&nbsp;&nbsp;&nbsp;WebDAVModule</td></tr> 
    <tr><th>Notification</th><td>&nbsp;&nbsp;&nbsp;MapRequestHandler</td></tr> 
    <tr class="alt"><th>Handler</th><td>&nbsp;&nbsp;&nbsp;aspNetCore</td></tr> 
    <tr><th>Error Code</th><td>&nbsp;&nbsp;&nbsp;0x00000000</td></tr> 
     
   </table> 
  </div> 
  <div id="details-right"> 
   <table border="0" cellpadding="0" cellspacing="0"> 
    <tr class="alt"><th>Requested URL</th><td>&nbsp;&nbsp;&nbsp;http://mywebsite.com:80/api/v2/package/</td></tr> 
    <tr><th>Physical Path</th><td>&nbsp;&nbsp;&nbsp;C:\inetpub\bagetter\api\v2\package\</td></tr> 
    <tr class="alt"><th>Logon Method</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> 
    <tr><th>Logon User</th><td>&nbsp;&nbsp;&nbsp;Anonymous</td></tr> 
     
   </table> 
   <div class="clear"></div> 
  </div> 
 </fieldset> 
</div> 
 
<div class="content-container"> 
 <fieldset><h4>More Information:</h4> 
  This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request. 
  <p><a href="https://go.microsoft.com/fwlink/?LinkID=62293&amp;IIS70Error=405,0,0x00000000,17763">View more information &raquo;</a></p> 
   
 </fieldset> 
</div> 
</div> 
</body> 
</html> 

Pushing a package does indeed use the /api/v2/package endpoint, that part is ok.

The BaGetter log you provided implies, the request never made it to BaGetter. I think the error page you got is provided by IIS.
WebDAV, when installed, can interfere with normal handling of requests. Please open the site in IIS and remove WebDAV from 1) Handler Mappings and 2) Modules, if it's there.

If this does not fix it, please enable IIS failed request tracing so we can figure out exactly where the request gets stuck.

Thank you, removing WebDAV from the Handler Mappings and Modules worked.