OneZoom / OZtree

OneZoom Tree of Life Explorer
Other
91 stars 20 forks source link

JS TypeError in OZentry, when evaluating e.length #827

Closed hyanwong closed 7 months ago

hyanwong commented 7 months ago

When testing the "new" prod, I'm getting the following error. Perhaps the API is failing because of not having a valid cert. Nevertheless, I suspect it should be failing more gracefully?

Screenshot 2024-04-24 at 15 26 30
lentinj commented 7 months ago

I'm fairly sure this is what happens if an attempt to fetch node details returns no results (read: the DB is empty).

Fairly sure it's 'nowt to do with certs, but it should certainly be failing more gracefully.

hyanwong commented 7 months ago

Thanks. This is running from the production DB, so I would hope it wasn't empty (and indeed it seems not to be, when I log directly into the database)

lentinj commented 7 months ago

Yup, if you look at the network tab the https://www.onezoom.org/API/node_details.json calls are returning no nodes. That's the root of the error, but as you say, it really shouldn't be empty.

hyanwong commented 7 months ago

Ah, maybe it's because it's asking via https then? I can't actually seem to visit the http:// version of the site: it switches me back to https even if I clear the website details. So I can't test it until we have proper certs for the new site

lentinj commented 7 months ago

It's not related to the self-signed certs, there's server-side upset:

With new onezoom:

$ curl https://www.onezoom.org/API/node_details.json --insecure --data-raw 'node_ids=195509%2C195510%2C195511&image_source=best_any'
{}

With old onezoom (i.e. /etc/hosts bodge commented out):

$ curl https://www.onezoom.org/API/node_details.json --insecure --data-raw 'node_ids=195509%2C195510%2C195511&image_source=best_any'
{"nodes":[[195509,null,44211.96582291409,null,null,0,0,0,0,1,1,0,0,0,3995689,3995702,null,null,null,null,null,null],[195510,null,null,null,null,0,0,0,0,0,3,0,0,0,3995662,3995684,null,null,null,null,null,null],[195511,null,44262.58643716552,null,null,0,0,0,0,0,2,0,0,0,3995684,null,null,null,null,null,null,null]],"leaves":[[195506,3995662,44211.96582291409,"Chrysodracon forbesii",null,1000],[195507,3995684,44313.20705141694,"Chrysodracon aurea",null,1000],[195504,3995689,44211.96582291409,"Chrysodracon fernaldii",null,1000],[195505,3995702,44211.96582291409,"Chrysodracon halapepe",null,1000]],"lang":"en","vernacular_by_ott":[[3995662,"Waianae Range hala pepe"],[3995684,"golden hala pepe"],[3995689,"Lanai hala pepe"],[3995702,"royal hala pepe"]],"vernacular_by_name":[],"leafIucn":[[3995662,"EN"],[3995684,"EN"],[3995689,"EN"],[3995702,"VU"]],"leafPic":[[3995662,30804491,99,40000],[3995684,26934277,99,25000],[3995689,27965724,99,40000],[3995702,30804496,99,40000]],"reservations":[]}

The {} could be from an exception that's been caught and hidden.

lentinj commented 7 months ago

Yup. The problem will be somewhere behind this:

https://github.com/OneZoom/OZtree/blob/fb96f14ff9802aaa25827f0aeb7e0180a450bb38/controllers/API.py#L87-L88

My bet would be it complaining about a lack of ordered_nodes.rnk.

hyanwong commented 7 months ago

Ah, thanks for the triage. The ordered_nodes.rnk field is there and full of NULLs, but that's what it's like on the beta site too, so it's a bit puzzling.

hyanwong commented 7 months ago

Ah:

"Table 'onezoom_prod.tourstop' doesn't exist"
davidebbo commented 7 months ago

So just a matter of turning on migrate=1 in private/appconfig.ini?

hyanwong commented 7 months ago

Yep, I tried that, but for some reason it's not doing the migrations correctly, so I simply copied the table definition from beta using raw SQL. It seems to be working.