-
Notifications
You must be signed in to change notification settings - Fork 40
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
[REVIEW] Fix/root page issue #51
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs work and a test for the change
Added basic test |
ping |
Thank you for the tweaks @rosscdh. It is great to have a test. I went on to replicate the issue locally using the examples/multisite project provided with wagtail-bakery, with BAKERY_VIEWS = (
'wagtailbakery.api_views.PagesAPIDetailView',
'wagtailbakery.api_views.PagesAPIListingView',
'wagtailbakery.api_views.TypedPagesAPIListingView',
) in settings.py. It still fails with File "wagtail-bakery/src/wagtailbakery/api_views.py", line 91, in build_queryset
[self.build_object(o) for o in self.get_queryset()]
File "wagtail-bakery/src/wagtailbakery/api_views.py", line 91, in <listcomp>
[self.build_object(o) for o in self.get_queryset()]
File "wagtail-bakery/src/wagtailbakery/api_views.py", line 85, in build_object
page_content = self.get_content(obj)
File "wagtail-bakery/src/wagtailbakery/api_views.py", line 114, in get_content
handle_api_error(response)
File "wagtail-bakery/src/wagtailbakery/api_views.py", line 25, in handle_api_error
raise APIResponseError("Unexpected status code returned from API: %d" % response.status_code)
wagtailbakery.api_views.APIResponseError: Unexpected status code returned from API: 404 Digging a bit deeper, the issue seem to be related to https://github.com/wagtail/wagtail-bakery/blob/28ae53756c7a0da3106411d969036fb2e3968b5b/src/wagtailbakery/api_views.py#L105 -- the Wagtail API will limit the returned pages to the requesting site. So even though we're passing a list of pages from all both sites, it will successfully render the default site ones, then fail with a 404 for the first page in a non-default site changing that line to This would need a test too. Last, but not least, the reason the tests were failing with "limit cannot be higher than 20" API error is because of https://github.com/wagtail/wagtail/blob/master/wagtail/api/v2/pagination.py#L31, i.e. if Sounds nitpicky, but the PR introduces a new setting which remains undocumented. My preference with the setting, to be on the safe side would be to wrap it in a method that will be defensive about |
Kept getting 404 on multisite true. Turns out, this was caused by the "root" page was being included in the result set.