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

NoneType' object has no attribute 'actor' #1849

Closed
simonw opened this issue Oct 24, 2022 · 5 comments
Closed

NoneType' object has no attribute 'actor' #1849

simonw opened this issue Oct 24, 2022 · 5 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Oct 24, 2022

  File "/usr/local/lib/python3.10/site-packages/datasette/templates/_crumbs.html", line 3, in template
    {% set items=crumb_items(request=request, database=database, table=table) %}
  File "jinja2/async_utils.py", line 65, in auto_await
    return await t.cast("t.Awaitable[V]", value)
  File "datasette/app.py", line 638, in _crumb_items
    actor=request.actor, action="view-instance", default=True

From Sentry.

@simonw simonw added the bug label Oct 24, 2022
@simonw
Copy link
Owner Author

simonw commented Oct 24, 2022

Looks like the new breadcrumbs code can't handle the case where request is None.

Need a test that demonstrates this too.

@simonw
Copy link
Owner Author

simonw commented Oct 24, 2022

@simonw
Copy link
Owner Author

simonw commented Oct 26, 2022

This was a hit to an authenticated page where the incoming user WAS logged in but did not have permission to view that specific page.

Code in question:

datasette/datasette/app.py

Lines 634 to 640 in c7dd76c

async def _crumb_items(self, request, table=None, database=None):
crumbs = []
# Top-level link
if await self.permission_allowed(
actor=request.actor, action="view-instance", default=True
):
crumbs.append({"href": self.urls.instance(), "label": "home"})

@simonw
Copy link
Owner Author

simonw commented Oct 26, 2022

From the stack trace in Sentry:

image

So this happened because a custom plugin tried to render forbidden.html without passing in the request.

@simonw
Copy link
Owner Author

simonw commented Oct 26, 2022

Generally though we should expect that people might try to use render_template(...) without passing a request, so Datasette core should be able to handle this.

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

No branches or pull requests

1 participant