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

Content Library: many searches causing 500s #72

Closed
gunsch opened this issue Sep 7, 2022 · 4 comments · Fixed by #95 · May be fixed by #73
Closed

Content Library: many searches causing 500s #72

gunsch opened this issue Sep 7, 2022 · 4 comments · Fixed by #95 · May be fixed by #73
Assignees

Comments

@gunsch
Copy link

gunsch commented Sep 7, 2022

i.e.
https://content-library.adhoc.pizza/search?q=accessibility&types=

triggers a 500 :(

@timwright12
Copy link

Not sure hoe helpful this is for debugging, but in testing this a little further and there are some substrings in "accessibility" that throw the 500 error as well:

Fail (500 error):

  • a
  • acce
  • acces
  • access
  • accessib
  • accessibility

Pass (returns):

  • ac
  • acc
  • accessi
  • accessibi
  • accessibil
  • accessibili
  • accessibilit

Single letters that throw a 500 error:

  • a
  • i
  • t

@timwright12
Copy link

Error from the log:

    error: {
      errors: [
        {
          domain: 'global',
          reason: 'invalid',
          message: 'Invalid Value',
          locationType: 'parameter',
          location: 'pageToken'
        }
      ],
      code: 400,
      message: 'Invalid Value'
    }

@bkjohnson
Copy link

So far it seems like what's used in a deployment doesn't match code that's used when running things locally. I removed this entire chunk from the handlePage function which handles when the /search page is hit:

const {q, autocomplete, types} = req.query
if (page === 'search' && q) {
return search.run(q, types, driveType).then((results) => {
// special rule for the autocomplete case, go directly to the item if we find it.
if (autocomplete) {
// filter here first to make sure only _one_ document exists with this exact name
const exactMatches = results.filter((i) => i.prettyName === q)
if (exactMatches.length === 1) return res.redirect(exactMatches[0].path)
}
res.format({
html: () => {
res.render(template, {q, results, template: stringTemplate, iconTypes, fileTypeNames})
},
json: () => {
res.json(results.map((result) => ({
url: result.path,
title: result.prettyName,
lastUpdatedBy: (result.lastModifyingUser || {}).displayName,
modifiedAt: result.modifiedTime,
createdAt: result.createdTime,
id: result.id,
resourceType: result.resourceType,
fileTypeNames
})))
}
})
})
}

Locally I end up with something like this (notice the "hello" in the query params):

The server running locally with the /search page open in the browser. The query string in the URL shows that "hello" was the search term, but the page shows that an empty string was used.

But when I deploy the code to a dev environment using gcloud, nothing changes. I still get the 500 error on search terms that I would get it on previously, and I still get search results on terms that worked previously.

@timwright12
Copy link

@bkjohnson maybe some heavy caching that needs to be cleared out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants