mapbox / mapbox-studio-classic

https://www.mapbox.com/mapbox-studio/
BSD 3-Clause "New" or "Revised" License
1.14k stars 229 forks source link

better validation for source URLs #651

Open jfirebaugh opened 10 years ago

jfirebaugh commented 10 years ago

If you put a bad URL into the Sources dialog and click "Update", you can get some interesting/confusing behavior.

E.g. a URL which is a 200 but doesn't send TileJSON --> cryptic parse error.

Or https://a.tiles.mapbox.com/v4/jfire.hj4lo84b.json (v4 API URL without access token) --> JS error, and Mapbox Studio is de-authorized.

rcoup commented 9 years ago

In addition to this, valid URLs are dropped (silently) c/- the HTML5 form validation

eg. http://example.com/foo;bar=1/~bob,jim and even the fully URL-encoded version http://example.com/foo%3Bbar%3D1/~bob%2Cjim fail the pattern

I think relaxing it to something like the below would probably be okay?

<form class='js-remotedata ...
  <input class='col9' ... pattern='((([\w-]+\.[\w-]+),?)+)|(https?://[^ ]+)' ...>
nvkelso commented 9 years ago

@rmarianski and I are hitting this, too, when implementing the newer API_KEY bit of tilejson for Mapzen's MVT format vector tiles in https://github.com/mapzen/vector-datasource/issues/311.

In other words, loading the old (below) works fine:

http://vector.mapzen.com/osm/tilejson/mapbox.json

And loading the new (below) never loads at all in Studio 0.2.7 and Studio Classic 0.3.2 for me.

http://vector.dev.mapzen.com/osm/tilejson/mapbox.json

With the only difference being shown with the post append of ?api_key={api_key}:

http://vector.dev.mapzen.com/osm/all/{z}/{x}/{y}.mvt?api_key={api_key}

When I view the web app loading it in Chrome with http://localhost:3000/, I get the following error:

http://localhost:3000/style/15/9650/12313@2x.png?id=tmpstyle:///Application…p/Contents/Resources/app/node_modules/mapbox-studio-default-style&ig8uvxvg 404 (Not Found)

style?id=tmpstyle:///Applications/Mapbox Studio.app/Contents/Resources/app/node_modules/mapbox-stud…:15250

Is there a workaround now or should we hold off implementing that until #1077 lands?

wilhelmberg commented 9 years ago

@nvkelso @rmarianski

Works for me (kind of):

image

Looks like a server problem on your side.

What happens, when you open one of the 404 URLs with the browser?

Most of the time I get a timeout message, that also shows in Studio for me:

image

Requesting a single tile via browser, e.g.

http://vector.dev.mapzen.com/osm/all/12/2234/1420.mvt?api_key=<MY_API_KEY>

results in this:

image

or takes ~20 to ~30 seconds to deliver the one tile:

ClientConnected: 10:53:35.514
ClientBeginRequest: 10:53:35.741
GotRequestHeaders:  10:53:35.741
ClientDoneRequest:  10:53:35.741
Determine Gateway:  0ms
DNS Lookup:         59ms
TCP/IP Connect: 61ms
HTTPS Handshake:    0ms
ServerConnected:    10:53:35.862
FiddlerBeginRequest:    10:53:35.862
ServerGotRequest:   10:53:35.863
ServerBeginResponse:    10:53:59.643
GotResponseHeaders: 10:53:59.643
ServerDoneResponse: 10:54:00.055
ClientBeginResponse:    10:54:00.056
ClientDoneResponse:  10:54:00.057
wilhelmberg commented 9 years ago

@nvkelso @rmarianski If you change the request timeout in your local Mapbox Studio Classic here you should see tiles appear. I set it to 60000 (1 minute) and most of the tiles appear, some still timeout.