ProjectSidewalk / SidewalkWebpage

Project Sidewalk web page
http://projectsidewalk.org
MIT License
80 stars 23 forks source link

Bug in query to get labels for Gallery #3588

Closed misaugstad closed 4 days ago

misaugstad commented 4 days ago
Brief description of problem/feature

I was looking for images using Gallery and came across an issue where the page wasn't loading labels when I put in a certain set of filters. I haven't really had problems with Gallery in the past. I need to leave for vacation soon, so I created a db dump of the city where this happened to me (St. Louis). This is the URL I was trying to use that caused the issue: https://sidewalk-st-louis.cs.washington.edu/gallery?labelType=SurfaceProblem&tags=narrow%20sidewalk&severities=5

Since I made a db dump, it should be reproducible when I have a chance to get back to this!

Here's the error message from the logs:

! @863aklo5m - Internal server error, for (POST) [/label/labels] ->

play.api.Application$$anon$1: Execution exception[[SlickException: Caught exception while computing default value for Rep[Option[_]].getOrElse -- This cannot be done lazily when the value is needed on the database side]]

Potential Solutions

I suppose that the issue is likely with this recent commit of mine (https://github.com/ProjectSidewalk/SidewalkWebpage/commit/31749a8bfca3d8b440e59df6363397f55af38df2) where I added lat/lngs to the data returned by this query. But I used the same process for doing that that I've used elsewhere... My guess is that we can't use .get on the lat/lng values until after we've executed the query and turned them into Scala objects. There are other cases where we call .get before executing the query, but in those cases I don't think that we do any further SQL operations, so maybe it's just not a problem if it's the last thing we do before executing.

misaugstad commented 4 days ago

After writing this, I started running into the issue constantly. Since it turned out to be more common than I'd thought, I went ahead and tested out my fix. It worked so I just merged it and will be pushing to prod soon.