question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

extra_template_vars() sending wrong view_name for index

See original GitHub issue

See https://github.com/simonw/museums/issues/20#issuecomment-609103663 - at some point between 286ed286b68793532c2a38436a08343b45cfbc91 and current master (e0e7a0facfc935a835cd73c720bc46661462f0b1 today) a bug was introduced where the extra_template_vars(request, view_name) plugin hook started being passed None instead of index for the view_name parameter on the site index page.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Apr 5, 2020

You start git bisect by giving it a known bad commit and a known good one:

git bisect start master 286ed28 

Then you tell it to start running your script:

git bisect run python ../datasette-issue-716/check_view_name.py

Here’s what I got:

(datasette) ~/Dropbox/Development/datasette $ git bisect start master 286ed28
Bisecting: 30 revisions left to test after this (roughly 5 steps)
[dc80e779a2e708b2685fc641df99e6aae9ad6f97] Handle scope path if it is a string
(datasette) ~/Dropbox/Development/datasette $ git bisect run python ../datasette-issue-716/check_view_name.py
running python ../datasette-issue-716/check_view_name.py
Traceback (most recent call last):
...
Bisecting: 15 revisions left to test after this (roughly 4 steps)
[7c6a9c35299f251f9abfb03fd8e85143e4361709] Better tests for prepare_connection() plugin hook, refs #678
running python ../datasette-issue-716/check_view_name.py
Traceback (most recent call last):
...
Bisecting: 7 revisions left to test after this (roughly 3 steps)
[0091dfe3e5a3db94af8881038d3f1b8312bb857d] More reliable tie-break ordering for facet results
running python ../datasette-issue-716/check_view_name.py
Traceback (most recent call last):
...
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[ce12244037b60ba0202c814871218c1dab38d729] Release notes for 0.35
running python ../datasette-issue-716/check_view_name.py
Traceback (most recent call last):
...
Bisecting: 0 revisions left to test after this (roughly 1 step)
[4d7dae9eb75e5430c3ee3c369bb5cd9ba0a148bc] Added a bunch more plugins to the Ecosystem page
running python ../datasette-issue-716/check_view_name.py
Traceback (most recent call last):
...
70b915fb4bc214f9d064179f87671f8a378aa127 is the first bad commit
commit 70b915fb4bc214f9d064179f87671f8a378aa127
Author: Simon Willison <swillison@gmail.com>
Date:   Tue Feb 4 12:26:17 2020 -0800

    Datasette.render_template() method, closes #577
    
    Pull request #664.

:040000 040000 def9e31252e056845609de36c66d4320dd0c47f8 da19b7f8c26d50a4c05e5a7f05220b968429725c M	datasette
bisect run success

So 70b915fb4bc214f9d064179f87671f8a378aa127 introduced the bug!

0reactions
simonwcommented, Apr 5, 2020

The test ended up being a bit fiddly - here it is:

https://github.com/simonw/datasette/blob/09253817dea3c131553494f9b2eb9c03f94ae761/tests/test_plugins.py#L266-L317

I used tmp_path_factory here because the tmpdir fixture I usually use isn’t compatible with scope="session", and I wanted to only create those temporary plugins and templates directories once rather than create them for each run of the parametrized test function.

In writing this I realized that the name on the QueryView class wasn’t being used, because that class is currently just used for its .data() method:

https://github.com/simonw/datasette/blob/09253817dea3c131553494f9b2eb9c03f94ae761/datasette/views/database.py#L27-L31

https://github.com/simonw/datasette/blob/07e208cc6d9e901b87552c1be2854c220b3f9b6d/datasette/views/table.py#L224-L227

So I removed the name = "query" line since it was misleading.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found