Comments (3)
Yeah we're seeing this too only on specific routes. The one that's breaker for us is the CSV export URL. Potentially related to #1619
I'm gonna work on this issue next week because it's a show stopper for us using Datasette in prod.
from datasette.
I traced the problem down to two areas in the Datasette code and am working on a fix.
The first is in datasette/url_builder.py
inside the Urls.path
method:
datasette/datasette/url_builder.py
Lines 11 to 13 in 56adfff
In the last line, sometimes the path
here already has the base_url
prepended and the path is not an instance of PrefixedUrlString
so the base_url
gets added twice.
The second issue is datasette/app.py
inside the absolute_url
method:
Line 1151 in 56adfff
The path sometimes comes in here with a base_url
prepended but without a leading slash and the request.url
also has the base_url
at the end of the URL so this results in a double prepend of the base_url
.
I'm currently adding some tests, but it's very unclear what the intended functionality was with these methods. So far I have test cases on the datasette.urls.path
method like so:
@pytest.mark.parametrize(
"base_url,path,format,expected",
[
("/", "/", None, "/"),
(None, "/", None, "/"),
(None, "", None, ""),
("/prefix/", "/prefix/table/1", None, "/prefix/table/1"),
("/prefix/", "prefix/table/1", None, "prefix/table/1"),
("/prefix/", "/table/1", None, "/prefix/table/1"),
("/prefix/", "/table/1", "json", "/prefix/table/1.json"),
("/prefix/", "-/static/app.css", None, "/prefix/-/static/app.css"),
(None, "table/1", None, "table/1"),
(None, "table/1", "csv", "table/1.csv"),
(None, "-/static/app.css", None, "-/static/app.css"),
],
)
def test_url_path_construction(ds, base_url, path, format, expected):
ds._settings["base_url"] = base_url
actual = ds.urls.path(path, format=format)
assert actual == expected
assert isinstance(actual, PrefixedUrlString)
Working on profiling the app to see how it seems to be expecting to handle URLs and will add more tests onto path
as well as absolute_url
.
from datasette.
Tracking code here: https://github.com/brandonrobertz/datasette/tree/fix-repeated-base_url
from datasette.
Related Issues (20)
- JSON API: Does not support `Content-Type: application/json; charset=utf-8` HOT 2
- menu_links menu should support optional descriptions HOT 2
- Datasette shouldn't crash running against a database with missing extensions HOT 9
- The `-s` settings option resets to default other settings changed in `datasette.yaml` config files HOT 8
- Make CSRF failures less confusing HOT 4
- Serve noindex homepage copy at /-/ HOT 4
- Release 1.0a15 HOT 2
- Use internal database catatalog tables any time we need to list all tables
- Make primary key of a row in a table easily accessible to JavaScript
- Speed up table counts when displaying index and database pages HOT 12
- Spacing bug in database copy HOT 2
- Remove pint dependency from Datasette 1.0 HOT 3
- `insert-row: true` permission at the table level should over-ride `insert-row` at the database level HOT 3
- Confusing error if metadata.json contains nested data HOT 2
- ?_trace=1 bug: ASGI callable returned without completing response HOT 2
- Tracer should capture SQL queries that error or exceed their time limit HOT 1
- Suggested facets should only consider first 1000 rows HOT 5
- DateFacet suggestions are incredibly slow against large tables
- Stop counting at 10,000 on table view as well HOT 7
- Extend the default `_footer.html` template
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasette.