{"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-695113871", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 695113871, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NTExMzg3MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-18T22:30:17Z", "updated_at": "2020-09-18T22:30:17Z", "author_association": "MEMBER", "body": "I think I know what's going on here:\r\n\r\nhttps://github.com/dogsheep/dogsheep-beta/blob/0f1b951c5131d16f3c8559a8e4d79ed5c559e3cb/dogsheep_beta/__init__.py#L166-L171\r\n\r\nThis is a logic bug - the `compiled` variable could be the template from the previous loop!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 703970814, "label": "the JSON object must be str, bytes or bytearray, not 'Undefined'"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-694557425", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 694557425, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NDU1NzQyNQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-17T23:41:01Z", "updated_at": "2020-09-17T23:41:01Z", "author_association": "MEMBER", "body": "I removed all of the `json.loads()` calls and I'm still getting that `Undefined` error.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 703970814, "label": "the JSON object must be str, bytes or bytearray, not 'Undefined'"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-694554584", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 694554584, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NDU1NDU4NA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-17T23:31:25Z", "updated_at": "2020-09-17T23:31:25Z", "author_association": "MEMBER", "body": "I'd prefer it if errors in these template fragments were displayed as errors inline where the fragment should have been inserted, rather than 500ing the whole page - especially since the template fragments are user-provided and could have all kinds of odd errors in them which should be as easy to debug as possible.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 703970814, "label": "the JSON object must be str, bytes or bytearray, not 'Undefined'"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-694553579", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 694553579, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NDU1MzU3OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-17T23:28:37Z", "updated_at": "2020-09-17T23:28:37Z", "author_association": "MEMBER", "body": "More investigation in pdb:\r\n```\r\n(dogsheep-beta) dogsheep-beta % datasette . --get '/-/beta?q=pycon&sort=oldest' --pdb\r\n> /usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py(341)loads()\r\n-> raise TypeError(f'the JSON object must be str, bytes or bytearray, '\r\n(Pdb) list\r\n336 \t if s.startswith('\\ufeff'):\r\n337 \t raise JSONDecodeError(\"Unexpected UTF-8 BOM (decode using utf-8-sig)\",\r\n338 \t s, 0)\r\n339 \t else:\r\n340 \t if not isinstance(s, (bytes, bytearray)):\r\n341 ->\t raise TypeError(f'the JSON object must be str, bytes or bytearray, '\r\n342 \t f'not {s.__class__.__name__}')\r\n343 \t s = s.decode(detect_encoding(s), 'surrogatepass')\r\n344 \t\r\n345 \t if \"encoding\" in kw:\r\n346 \t import warnings\r\n(Pdb) bytes\r\n\r\n(Pdb) locals()['s']\r\nUndefined\r\n(Pdb) type(locals()['s'])\r\n\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 703970814, "label": "the JSON object must be str, bytes or bytearray, not 'Undefined'"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-694552681", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 694552681, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NDU1MjY4MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-17T23:25:54Z", "updated_at": "2020-09-17T23:25:54Z", "author_association": "MEMBER", "body": "This is the template fragment it's rendering:\r\n```html+jinja\r\n
\r\n

Tweet by @{{ display.screen_name }} ({{ display.user_name }}, {{ \"{:,}\".format(display.followers_count or 0) }} followers)\r\n on {{ display.created_at }}

\r\n

\r\n
{{ display.full_text }}
\r\n {% if display.media_urls and json.loads(display.media_urls) %}\r\n {% for url in json.loads(display.media_urls) %}\r\n \r\n {% endfor %}\r\n {% endif %}\r\n
\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 703970814, "label": "the JSON object must be str, bytes or bytearray, not 'Undefined'"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-694552393", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 694552393, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NDU1MjM5Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-17T23:25:01Z", "updated_at": "2020-09-17T23:25:17Z", "author_association": "MEMBER", "body": "Ran `locals()` In the debugger:\r\n`{'range': , 'dict': , 'lipsum': , 'cycler': , 'joiner': , 'namespace': , 'rank': -9.383801886431414, 'rowid': 14297, 'type': 'twitter.db/tweets', 'key': '312658917933076480', 'title': 'Tweet by @chrisstreeter', 'category': 2, 'timestamp': '2013-03-15T20:17:49+00:00', 'search_1': '@simonw are you at pycon? Would love to meet you.', 'display': {'avatar_url': 'https://pbs.twimg.com/profile_images/806275088597204993/38yLHfJi_normal.jpg', 'user_name': 'Chris Streeter', 'screen_name': 'chrisstreeter', 'followers_count': 280, 'tweet_id': 312658917933076480, 'created_at': '2013-03-15T20:17:49+00:00', 'full_text': '@simonw are you at pycon? Would love to meet you.', 'media_urls_2': '[]', 'media_urls': '[]'}, 'json': }`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 703970814, "label": "the JSON object must be str, bytes or bytearray, not 'Undefined'"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-beta/issues/24#issuecomment-694551646", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-beta/issues/24", "id": 694551646, "node_id": "MDEyOklzc3VlQ29tbWVudDY5NDU1MTY0Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-09-17T23:22:48Z", "updated_at": "2020-09-17T23:22:48Z", "author_association": "MEMBER", "body": "Looks like its happening in a Jinja fragment template for one of the results:\r\n```\r\n /Users/simon/Dropbox/Development/dogsheep-beta/dogsheep_beta/__init__.py(169)process_results()\r\n-> output = compiled.render({**result, **{\"json\": json}})\r\n /Users/simon/.local/share/virtualenvs/dogsheep-beta-u_po4Rpj/lib/python3.8/site-packages/jinja2/asyncsupport.py(71)render()\r\n-> return original_render(self, *args, **kwargs)\r\n /Users/simon/.local/share/virtualenvs/dogsheep-beta-u_po4Rpj/lib/python3.8/site-packages/jinja2/environment.py(1090)render()\r\n-> self.environment.handle_exception()\r\n /Users/simon/.local/share/virtualenvs/dogsheep-beta-u_po4Rpj/lib/python3.8/site-packages/jinja2/environment.py(832)handle_exception()\r\n-> reraise(*rewrite_traceback_stack(source=source))\r\n /Users/simon/.local/share/virtualenvs/dogsheep-beta-u_po4Rpj/lib/python3.8/site-packages/jinja2/_compat.py(28)reraise()\r\n-> raise value.with_traceback(tb)\r\n