Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use where instead of find to prevent 404
- Loading branch information
Showing
2 changed files
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
xml.instruct! :xml, :version => "1.0" | ||
xml.osm(OSM::API.new.xml_root_attributes) do |osm| | ||
osm << render(@users) | ||
osm << (render(@users) || "") | ||
end |
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change for some of my apps. While I completely agree with the concept behind it, I don't agree with addressing it within API v0.6. I believe this should be introduced in a new API version instead. Breaking changes such as this should not be released at random.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have apps with do selects for multiple users and rely on getting 404 if any one of the users is missing?!? Was that ever documented anywhere as expected behaviour because I'm pretty sure it was only ever an accident and it really doesn't seem like sensible or useful behaviour.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a very common use case.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When dealing with widely-used APIs, it's crucial to exercise caution and avoid altering any existing behaviors. Releasing the changes under a new API version seems like a simpler approach. These changes as I see it are non-critical. Implementing random changes of this nature can undermine the projects reliability for developers. Isn't that a common sense?
Regardless of whether the change was accidental or intentional, established API methods should remain consistent. This principle is fundamental to creating a dependable and esteemed API. Even the slightest modifications pose a risk of disrupting applications for users. It would be reasonable to designate this change with a new version, as it's a non-critical modification.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use
/api/0.6/users?users
to fetch single users instead of/api/0.6/user
?b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, batched:
https://www.openstreetmap.org/api/0.6/users.json?users=20113056,20113059,20113060,20113061,20113065,20113067,20113069,20113072,20113073,20113075,20113079,20113092,20113097
This returns 200 now and breaks my logic completely. I previously expected 404 here.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you expect 404 when one user was missing or when all of them were?
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomhughes Shouldn't such changes be publicized on the forum before they are implemented?
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previous logic worked this way:
While a very weird behavior indeed, I wrote my code around this issue. I have seen worse things in my life.
The current logic works this way:
My previously coded applications are not ready for such change, this is not backwards compatible, thus: breaking change.
The green lines are additions I had to do today when I noticed my app stopped working:
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put new behavior on a different endpoint, for example
/api/0.6/users/search
(similar to/api/0.6/notes/search
).b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or 0.7. Why is community scared of releasing a new API version with improvements - it's just a number. If for some reason you want to stay on 0.6 - sure - but please don't change its behavior.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
404s if even a single thing is missing are especially annoying during element multifetches, where you ask for hundreds of items.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree, but this is unfortunately a breaking change. Code has already been written and changes like these undermine the reliability of the OSM API. Please don't waste peoples time just because.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then two versions will have to be supported in parallel, or almost every api client will be broken.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very common to see nowadays. What's exactly the issue here because I don't fully understand it. If you want to make any significant improvements, you do it under a new version. That's how API development works - no? This is not an ordinary website/client/mobile app development.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With changes like here you'll quickly get to 0.10 and five api versions active at the same time.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How exactly does this help the situation in any way? I am trying to help. Today's changes simply broke the backwards compatibility and I wanted to point out that behavior like this is very odd, surprising, and must be avoided. This is a non-critical update and there is no reason for it to break peoples applications.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm saying that doing api 0.7 just for user multifetches without 404s is not a good idea and a new api version is not just a number. Keeping one
api/users#index
method in addition to/api/0.6/users/search
is going to be easier than keeping api 0.6 together with api 0.7.search
endpoint later can be extended for date ranges, like other search endpoints. Then the old endpoint can be declared deprecated and api 0.7 will have it dropped.b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I understand. However, I didn't suggest that we make the switch to 0.7 solely due to the multifetch change. My idea is that we accumulate enhancements gradually and then introduce version 0.7, instead of repeatedly patching up 0.6. It's important to strike a balance here. Having a significant version update every 2-4 years seems quite reasonable to me.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but as I understand it this was an urgent change to assist DWG with their efforts to fight the ongoing vandalism which is why I was keen to merge and deploy it as quickly as possible - obviously we had not anticipated that people would rely on either the ordering or the 404 behaviour.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your point. Identifying non-obvious breaking changes can be challenging. However, the manner in which you address such issues is crucial. Making assertive statements like the ones, b9c85c2#commitcomment-125593592, be96aa7#commitcomment-125593392, is, in my opinion, not the most effective approach. A more constructive method of handling such situation would be welcome.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed c7a31eb to restore the ordering.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide an update on this issue, @tomhughes? I commend your efforts in restoring the ordering, but it seems slightly off-topic considering the context of this commit and this conversation.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What sort of update would you like? The ordering change has been reverted and there are no current plans to make any other changes.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you actually reviewed the discussion? Your response is very odd.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So new 404 behavior is going to stay?
Was any missing user response documented anywhere? Because if not, the only way to use this endpoint was to read the source code and expect it to keep working as it did before.
Elements multifetches behave the same way, so you can't be so sure.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that this will be the case. It is quite perplexing that @tomhughes opted to disrupt individuals' applications purely for the sake of optimization. This alteration doesn't bring forth any new functionalities, and as I highlighted, the prior version, despite its inefficiency, could operate in precisely the same manner as it does "currently". This situation raises significant concerns about the trajectory of OSM API development.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did no such thing. I merged a change which seemed reasonable and which I did not anticipate would disrupt anybody. There was absolutely no intention to disrupt anybody.
The reference to optimisation related to ordering and that wasn't a deliberate attempt to optimise, it was entirely accidental because none of us realised that
find
preserved order. The mention of optimisation once that came of was because I thought maybe it was doing lots of single selects which would be horrible but it doesn't and in any case I have reverted the entirely accidental ordering change now.b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zaczero, I'd suggest to tone down your outrage a little. In my eyes, it is not a "breaking" change if undocumented behaviour changes. And it clearly is a change for the better, bringing the user multi-fetch in line with the other multi-fetches already existing. I can understand that it is annoying if you have to change your application - perhaps even after your application's users writing to you and complaining about it not working. Of course it would be nice if everyone could comfortably rely on OSM providing several APIs in parallel so that everyone can upgrade their app to the latest API at leisure. But resources - personnel and otherwise - are limited, and we can't afford that. We regularly change the existing API in minuscle ways that are unlikely to trip up anyone but that do change the behaviour at little, and things might break. So in this case it was you who had to bear a tiny little bit of the work that we all do, as volunteers, on a regular basis. I, for one, am happy that small and sensible changes like this do not have to go through a two-year staging process. Yet ;)
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the majority consensus leans toward accepting the sacrifice of backward compatibility in the name of optimization, then let it be so. Thank you for the clarification.
My concern regarding optimization pertains specifically to this commit, not the other sorting-related change. This change specifically didn't introduce fresh functionality; it merely enhanced efficiency, as evidenced by my previous code example (performing binary search on 404). While I wholeheartedly support this modification, I firmly believe it should not have been executed in a manner that breaks compatibility. This, I perceive, is a lack of consideration for developers who utilize this API.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zaczero you might be right, but this might not be the best way of saying it. Remember to assume good faith, and that OSM is a community project - we have to work with each other instead of against each other. It sucks when undocumented behaviour breaks and you have to change your code, but that's the faustian bargain you make when you rely on it. Tom and ENT8R do this in their spare time, can't be expected to know every way in which the API is being (ab)used.
"Every change breaks someone's workflow"
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree @grischard. This is precisely why I opted to shed light on this matter. The predicament lies in the fact that despite my explicit description of the breaking change, no action is being taken to correct it; instead, it's being acknowledged without resolution.
This modification has impacted the only efficient method for querying the most recent user information. This is not some obscure workflow.
PS. This breaking change was actually anticipated. By reviewing the pull request, you'll observe the corresponding test modifications to ensure their success. What even is the point of having tests then?
#4203
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no way not to rely on it. And in case of elements multifetch, it was documented: https://wiki.openstreetmap.org/wiki/API_v0.6#Error_codes_21
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't break iD because there seems to be no error handling:
https://github.com/openstreetmap/iD/blob/68ff64b01d5a125950474dbf567bc0a9fa3b9edd/modules/services/osm.js#L896
Users are requested only together with notes and deleted users' note comments are hidden by the api.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, this didn't happen:
Now we're up to three different styles of multifetches:
Previously it was two, without the middle one.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I often presume the accuracy of information shared by individuals. Unfortunately, I had to verify the claim that "this was undocumented behavior", and it turns out to be false.
In the API v0.6 documentation, search for "or an empty file if no user found for given identifier" (2nd result). Despite what the documentation states, the following requests do not yield an empty file:
(they did yield an empty file before this breaking change)
At this point, I'm struggling to comprehend the rationale behind persistently presenting such erroneous arguments. It's quite peculiar that a head of development cannot acknowledge their errors and, instead, shifts blame onto others' code. The concepts we're discussing here are fundamental to code development, and it appears that some individuals lack a basic understanding of them. This entire conversation has proven quite draining for me. Despite my best attempts to highlight the issues, it seems unlikely that corrective measures will be taken. Such changes demonstrate a lack of respect for individuals utilizing this API. Hopefully, this will change for the better in the future.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please understand that the "documentation" you refer to is not written by us and has no official status - that is essentially documented by users reverse engineering and assuming the current behaviour is correct and documenting it.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is getting quite silly... Where can I find the "official" documentation? Is every behavior undefined?
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no official documentation.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. In that case, it's crucial to inform users of https://wiki.openstreetmap.org/wiki/API_v0.6 that this documentation is unofficial and that any behaviors outlined there should be regarded as subject to change in the future. Essentially, there is no consistent 0.6 behavior. It's a bit ironic for me to observe that instead of acknowledging the mistake, the conversation continues with such perplexing arguments.
I find it quite surprising that there isn't an official OSM API behavior. Why hasn't this been addressed before? It appears to be a significant oversight. How can people be expected to develop apps on OSM without a such a fundamental standard?
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zaczero, please take a step back and ask yourself why this whole discussion is "draining" and if perhaps your own style of discussion contributes to that situation. Personally, I find most of your posts rather condescending; there's hardly any sentence in which you do not accuse others of doing things "at random", of making things "unreliable", of being "not reasonable", of being "odd", of having "opted to disrupt", of "sacrificing" something. Even if you were 100% right, this righteous attitude will drain everyone's resources, and everyone's willingness to deal with you.
Just change those few lines of code in your application and accept that OSM is a moving project driven by volunteers, and not a commercial endeavour where people pay millions to have a guaranteed API with release cycles and all.
And please, refrain from sullenly putting a huge red box on top of the API documentation on the wiki pointing out how unreliable and unofficial everything is. Because you could do that on every wiki page ;)
And maybe you can even swallow that defiant one-liner you'd like to reply to this message with, and let us all, including yourself, get back to more productive things for OSM.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGImap maintainer here. The OSM APi 0.6 Wiki page now displays an ambox including the text "Every behavior described here results from reverse engineering". I don't think this is accurate the way it has been stated there, since I won't be reverse engineering my own code at least.
Originally I have added the comment ""or an empty file if no user found for given identifier". That "empty file" should read as "JSON document with empty users array". Probably just a sloppy way of documenting the JSON result. You're invited to correct it, it's a Wiki after all.
Don't get too much hooked up that there's no official documentation. That's ok, everyone knows it. It's been this way since the beginning, and unlikely to change anytime soon. We have some ideas to include the documentation in this repo, and automatically generate the documentation. Unfortunately, there's not enough bandwidth for such topics, since, as you probably know, we all do this here in our spare time as volunteers. Again, you're invited to help improving things. Until then, the OSM API 0.6 Wiki page is the best documentation available. I try to keep it up-to-date with changes, as do many others, but I don't always have time to work on it.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmd-osm Thank you for your input. I've revised the text on the wiki as follows:
This revision should more accurately reflect the current status. As this is the only API documentation available, it's crucial to inform developers about its unofficial nature and potential for change. This type of information might come as a surprise given the project's size, so it's better to be transparent about it.
The landscape of the OSM project today differs from its state a decade ago. With more developers, including commercial ventures, relying on this project, having dependable documentation becomes critical. Once again, this appears to be a significant oversight.
Personally, the distinction between official and unofficial doesn't concern me greatly. What I care about the most is writing reliable software. If we're at the point where we decide to intentionally change tests and go against the only available documentation (the consensus), this is a major red flag for me.
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot here in this conversation, so I'll be brief:
b9c85c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4207