urbit / urbit

An operating function
https://urbit.org
MIT License
3.42k stars 358 forks source link

docket globulator fails #5282

Closed tinnus-napbus closed 2 years ago

tinnus-napbus commented 3 years ago

Describe the bug Docket globulator fails with the following error after hitting glob!:

Internal Server Error
There was an error while handling the request for /docket/upload.

/app/docket/hoon:<[511 20].[511 44]>
/app/docket/hoon:<[511 7].[546 9]>
/app/docket/hoon:<[510 7].[546 9]>
/app/docket/hoon:<[509 5].[581 39]>
/app/docket/hoon:<[506 5].[581 39]>
/app/docket/hoon:<[505 5].[581 39]>
/app/docket/hoon:<[419 18].[419 31]>
/app/docket/hoon:<[417 7].[420 9]>
/app/docket/hoon:<[417 3].[624 5]>
/app/docket/hoon:<[415 3].[624 5]>
/app/docket/hoon:<[414 3].[624 5]>
/app/docket/hoon:<[409 3].[624 5]>
/app/docket/hoon:<[402 3].[624 5]>
/app/docket/hoon:<[400 3].[624 5]>
/app/docket/hoon:<[85 7].[85 38]>
/app/docket/hoon:<[84 7].[85 38]>
/app/docket/hoon:<[75 5].[86 7]>
/app/docket/hoon:<[74 3].[87 15]>
/app/docket/hoon:<[73 3].[112 5]>
/app/docket/hoon:<[72 3].[112 5]>
/sys/vane/gall/hoon:<[1.371 9].[1.371 37]>

Additionally, it spits out these headers in the dojo:

  headers
~[
  [key='host' value='localhost:8080']
  [key='connection' value='keep-alive']
  [key='cache-control' value='max-age=0']
  [key='sec-ch-ua' value='";Not A Brand";v="99", "Chromium";v="94"']
  [key='sec-ch-ua-mobile' value='?0']
  headers
~[
  [key='host' value='localhost:8080']
  [key='connection' value='keep-alive']
  [key='cache-control' value='max-age=0']
  [key='sec-ch-ua' value='";Not A Brand";v="99", "Chromium";v="94"']
  [key='sec-ch-ua-mobile' value='?0']
  [key='sec-ch-ua-platform' value='"Linux"']
  [key='upgrade-insecure-requests' value='1']
  [key='origin' value='http://localhost:8080']
  [ key='content-type'
    value='multipart/form-data; boundary=----WebKitFormBoundaryfzby8ri0tkY5NRFh'
  ]
  [ key='user-agent'
      value
    'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36'
  ]
  [ key='accept'
      value
    'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
  ]
  [key='sec-fetch-site' value='same-origin']
  [key='sec-fetch-mode' value='navigate']
  [key='sec-fetch-user' value='?1']
  [key='sec-fetch-dest' value='document']
  [key='referer' value='http://localhost:8080/docket/upload']
  [key='accept-encoding' value='gzip, deflate, br']
  [key='accept-language' value='en-GB,en-US;q=0.9,en;q=0.8']
  [key='cookie' value='urbauth-~zod=0vbdobj.u0d0d.64q1u.3tk7u.fhkqo']
]

To Reproduce Steps to reproduce the behavior:

  1. Go to `localhost:8080/docket/upload
  2. Select target desk
  3. Select folder to glob
  4. glob!
  5. see error

Expected behavior should upload glob successfully

Operating context

tinnus-napbus commented 3 years ago

ok I |commited latest desks from urbit github rather than just using multi.pill but I still get the same thing:

Internal Server Error
There was an error while handling the request for /docket/upload.

/app/docket/hoon:<[514 20].[514 44]>
/app/docket/hoon:<[514 7].[549 9]>
/app/docket/hoon:<[513 7].[549 9]>
/app/docket/hoon:<[512 5].[584 39]>
/app/docket/hoon:<[509 5].[584 39]>
/app/docket/hoon:<[508 5].[584 39]>
/app/docket/hoon:<[422 18].[422 31]>
/app/docket/hoon:<[420 7].[423 9]>
/app/docket/hoon:<[420 3].[627 5]>
/app/docket/hoon:<[418 3].[627 5]>
/app/docket/hoon:<[417 3].[627 5]>
/app/docket/hoon:<[412 3].[627 5]>
/app/docket/hoon:<[405 3].[627 5]>
/app/docket/hoon:<[403 3].[627 5]>
/app/docket/hoon:<[85 7].[85 38]>
/app/docket/hoon:<[84 7].[85 38]>
/app/docket/hoon:<[75 5].[86 7]>
/app/docket/hoon:<[74 3].[87 15]>
/app/docket/hoon:<[73 3].[112 5]>
/app/docket/hoon:<[72 3].[112 5]>
/sys/vane/gall/hoon:<[1.372 9].[1.372 37]>
Fang- commented 3 years ago

That looks like it's failing here:

https://github.com/urbit/urbit/blob/c6b4ff11fe80a88d06f0f294f3f68f282bbd44d2/pkg/garden/app/docket.hoon#L514

Which is very strange, because desk at that point has already gotten sanity-checked:

https://github.com/urbit/urbit/blob/c6b4ff11fe80a88d06f0f294f3f68f282bbd44d2/pkg/garden/app/docket.hoon#L558-L565

Of course, if it's absent from the request entirely, then that's not going to get hit, and desk will remain the empty name, which will indeed crash.

I cannot reproduce this locally, so if you don't mind, you could try putting the following before line 514 (after the =;) in /=garden=/app/docket.hoon:

~|  [%glob-upload desk=desk]
~?  !=(~ err)  errors=err

Commit that, then try again and see what output that gives.

Might also be valuable to go into the browser console's networking tab, and try to see if the outgoing POST request (upon clicking the glob button) does or does not contain something along the lines of:

-----------------------------38147362104607528703095340636
Content-Disposition: form-data; name="desk"

yourdeskname
-----------------------------38147362104607528703095340636
[big ol' file contents]
tinnus-napbus commented 3 years ago

the error I get with those added lines is:

errors=<|failed to parse submitted data|>

I checked the request payload and it does indeed proceed like:

-----------------------------568509388155302009861853530
Content-Disposition: form-data; name="desk"

hello
-----------------------------568509388155302009861853530
Content-Disposition: form-data; name="glob"; filename="hello/index.html"
Content-Type: text/html

<!DOCTYPE html>
<html>
  <head>
    <style>
      div {text-align:center}
    </style>
  </head>
  <title>Hello World</title>
  <body>
    <div>
      <h1>Hello World!</h1>
      <img src="img/pot.svg" alt="pot" width="219" height="196">
    </div>
  </body>
</html>

-----------------------------568509388155302009861853530
Content-Disposition: form-data; name="glob"; filename="hello/img/pot.svg"
Content-Type: image/svg+xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   id="Layer_1"
   xml:space="preserve"
   overflow="visible"
   viewBox="0 0 250 250"
   version="1.1"
[.......and so on...........]