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

"Exception: No query supplied" in the listing block #3839

Closed
wesleybl opened this issue Nov 4, 2022 · 6 comments · Fixed by #6423 · May be fixed by #3866
Closed

"Exception: No query supplied" in the listing block #3839

wesleybl opened this issue Nov 4, 2022 · 6 comments · Fixed by #6423 · May be fixed by #3866

Comments

@wesleybl
Copy link
Member

wesleybl commented Nov 4, 2022

Describe the bug
When we load a page that has a listing block, without a search criteria, we get the error below in Plone:

2022-11-04 16:51:47 ERROR [Zope.SiteErrorLog:35][waitress-3] Exception: http://localhost:3000/@querystring-search
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module plone.rest.service, line 22, in __call__
  Module plone.restapi.services, line 19, in render
  Module plone.restapi.services.querystringsearch.get, line 30, in reply
Exception: No query supplied

Who makes this call is getAsyncData.js

It sends the query parameter as an empty list.

It looks like it's an attempt to render the block server-side, but I don't quite understand it. The fact is that the block works without getAsyncData. So I'm not quite sure what the idea is here.

To Reproduce
Steps to reproduce the behavior:

  1. Create a listing block at home, without any search criteria.
  2. Press F5 on home.
  3. See the Plone log.

Expected behavior
No error in Plone.

Software (please complete the following information):

  • OS: Ubuntu 22
  • Browser: Chrome
  • Volto Version: 16.0.0-alpha.48
  • Plone Version 6.0.0b3
  • Plone REST API Version: 8.30.0
@tiberiuichim
Copy link
Contributor

@wesleybl It's related to the server-side rendering of the listing block, see https://6.dev-docs.plone.org/volto/blocks/ssr.html

It's probably a bug, that code needs to be brought more in line with the rest of the listing block data fetching preparations.

@wesleybl
Copy link
Member Author

wesleybl commented Nov 4, 2022

@tiberiuichim i'm trying to modify the listing block, to return more calalog metadata. But I saw that there are requests in getAsyncData.js and in withQuerystringResults.jsx. Which of these files should I make changes to? Or on both?

@tiberiuichim
Copy link
Contributor

@wesleybl both.

getAsyncData is only used on the server-side rendering path. It's meant to populate the Redux store that will be used by the listing block components. Here's a page that hopefully will explain this mechanism: https://training.plone.org/effective-volto/addons/asyncconnect.html

withQuerystringResults is used by the listing block to fetch the data.

In principle these two functions should produce exactly the same query (pagination excluded, as there's no URL-based set current page). If they don't, it's a bug in the getAsyncData and should be fixed.

@wesleybl
Copy link
Member Author

wesleybl commented Nov 7, 2022

@tiberiuichim as I understand it, this is a mechanism to prevent the page from loading without the listing. But on the Browser side, the listing can be modified, after server rendering. That's it?

Well it looks like the way it is today, when we don't have a criterion, nothing is rendered on the server side (getAsyncData.js), since the query parameter is empty here (causing the described error).

The listing only appears because withQuerystringResults.js has a fallback:

} else {
dispatch(getContent(initialPath, null, null, currentPage));
}

when we don't have query.

It may be necessary to create a "default query", both in withQuerystringResults.js and in getAsyncData.js, when there is no query. Maybe in editing this "default query" should already be saved.

@wesleybl
Copy link
Member Author

wesleybl commented Nov 9, 2022

@tiberiuichim @sneridagh any opinions here? I propose the default query:

const defaultQuery = [
  {
    i: 'path',
    o: 'plone.app.querystring.operation.string.relativePath',
    v: '::1',
  },
];

when we have no defined criteria. This query will have the same result as the items key of the content.

@tiberiuichim
Copy link
Contributor

@wesleybl Ok, +1

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