tyrasd / overpass-turbo

A web based data mining tool for OpenStreetMap using the Overpass API.
https://overpass-turbo.eu
Other
891 stars 129 forks source link

Saving/deleting queries on osm.org is not working #666

Closed tguen closed 7 months ago

tguen commented 8 months ago

When I save a query, I enter a name in the dialog and click "save on osm.org". Then I open the load menu and it's not in the "Saved Queries (osm.org)" list, even after reloading the page. Clicking the (x) button on a query in the list gives me a confirmation dialog, and when I click delete, the query remains. No error messages are shown on the page or in the console.

hakuchi commented 8 months ago

same for me... tested with Chrome, Opera and Firefox

mnalis commented 8 months ago

do you even have that option after force-refresh (i.e. clearing the browser cache and/or ctrl-f5/ctrl-shift-r) ?

That feature seems to be missing completely for me, see https://github.com/tyrasd/overpass-turbo/issues/665

mnalis commented 7 months ago

After making sure to use https:// so that load/save on OSM option is visible, I can confirm that saving to OSM does not work anymore. I've tried force-refreshing, logging out and back in, with no change.

Saving does not save anything (this issue) and it also does not show any error or close the form (as reported in https://github.com/tyrasd/overpass-turbo/issues/534).

Looking in console, it fails with 400 bad request error when trying to PUT on https://www.openstreetmap.org/api/0.6/user/preferences :

XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, responseURL: "https://www.openstreetmap.org/api/0.6/user/preferences", status: 400, statusText: "Bad Request", responseType: "", response: "", responseText: "" }
index-fd1ab5c5.js:757:3528
Hufkratzer commented 7 months ago

Same for me. The last time I saved a query on the server, it worked; that was in May 2023. Then I haven't tried it again until now.

tyrasd commented 7 months ago

This bug is now fixed with 34fac47f29e7fac896c03be96b4c67b7dd9204a1.

mnalis commented 6 months ago

According to Help on https://overpass-turbo.eu/ (which says it is overpass-turbo 2023-12-16/ 6215541), that fix should be live now? However, I'm still unable (even after CTRL-F5 force refreshing, and logout/login) to save queries on osm.org, getting:

400 Bad request on that PUT https://www.openstreetmap.org/api/0.6/user/preferences:

XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, responseURL: "https://www.openstreetmap.org/api/0.6/user/preferences", status: 400, statusText: "Bad Request", responseType: "", response: "", responseText: "" }
index-544492d9.js:757:3528
Hufkratzer commented 6 months ago

I have just tested it and it worked for me.

mnalis commented 6 months ago

I have now tried it on another account (where I had no previous saved OSM queries) and save on osm.org works there.

I tried in same browser multiple times - one account works just fine, other fails to save any query on OSM. Even on failing account, the queries all seem to load just fine from OSM. The issue is just trying to save them

It thus seems likely that the issue might be related to previously stored queries. On problematic account, there are 16 Overpass-turbo queries saved, with total plaintext size of about 9.1kB. Is it perhaps hitting some limit?

@tyrasd do you need me to provide additional data to help track this down (and how would I gather it)?

tyrasd commented 6 months ago

Is it perhaps hitting some limit?

@tyrasd do you need me to provide additional data to help track this down (and how would I gather it)?

Hmm… Possibly. Although I could not trigger the documented limit of 150 preferences per user in a quick test where I was able to upload 200+ preferences in a single PUT request (~51kB of plain text xml). But even if the limit of 150 preferences were to hold, it should be plenty to store 16 queries (except maybe if the queries are particularly long).

Do you see any error messages in either the javascript console or the network tab of the browser's development tool?

mnalis commented 6 months ago

Do you see any error messages in either the javascript console or the network tab of the browser's development tool?

No other errors that I can see.

overpass2 overpass1

mnalis commented 6 months ago

Some interesting bits:


[...some time later, after messing with Copy as cURL and manually editing query...]

It seems that my OSM preferences of my problematic account contain some preferences from very old tools, with things like:

 <preference k="MerkaartorTmsServer003" v="OSM Mapnik;tile.openstreetmap.org;/%1/%2/%3.png;256;0;17"/>

While the whole thing seems like perfectly valid XML, by method of elimination I've found that OSM API aborts uploading the preferences which contain % character (IOW, when I remove all lines with %, I can manually PUT the preferences with curl(1), and when I leave even one of those lines, it fails to upload with 400 again).

So, because I was able to save new overpass-turbo queries at earlier point in time, it seems to me that either:

I should report that issue for API v0.6, so it can be either fix or at least documented.

mnalis commented 6 months ago

Reported at https://github.com/openstreetmap/openstreetmap-website/issues/4467

mmd-osm commented 5 months ago

So the issue is that overpass turbo sends the PUT https://www.openstreetmap.org/api/0.6/user/preferences with Content-Type application/x-www-form-urlencoded, although it should be application/xml.

I found this bit in https://github.com/tyrasd/overpass-turbo/blob/master/js/sync-with-osm.ts#L161 saying the the Content-Type should be text/xml, though somehow that's not what's used when sending out the request to osm.org server.

tyrasd commented 5 months ago

Aah, yes, you're right. Thanks for the pointer @mmd-osm. This should be fixed with 8db5c43. PS: this used to work correctly before I upgraded to osm-auth v2 (see 638643b, for OAuth2 support), but I had overlooked that there was a sneaky breaking API change for how to specify request headers.

mnalis commented 5 months ago

Thanks @mmd-osm and @tyrasd; I can confirm that I can now save queries on osm.org using my main OSM account again!