If a row has a primary key of `null` various things break
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.5k
- Forks
- 904
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 18
Description
Stumbled across this while experimenting with datasette-write-ui. The error I got was a 500 on the /db page:
'NoneType' object has no attribute 'encode'
Tracked it down to this code, which assembles the URL for a row page:
That's because tilde_encode can't handle None: https://github.com/simonw/datasette/blob/943df09dcca93c3b9861b8c96277a01320db8662/datasette/utils/__init__.py#L1175-L1178
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with datasette/utils/init.py, especially the row URL assembly and tilde_encode paths linked in the issue, and reproduce the failure from the /db entry point using a row whose primary key is null. Confirm that the resulting behavior no longer returns a 500 and that null-primary-key handling is covered by the relevant existing tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100