-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Partial success HTTP status codes #3054 #4003
Conversation
Conflicts: CHANGES_NEXT_RELEASE
Changing response codes is a decision that need to be done with care (it may have effect in backward compatibility). Thus, we are going to put this PR on hold while we can assure there is no problem in existing deployments. Thanks @Anjali-NEC for your contribution! |
@fgalan Gentle Reminder !! |
@@ -108,9 +108,9 @@ Date: REGEX(.*) | |||
"type": "T" | |||
}, | |||
"statusCode": { | |||
"code": "422", | |||
"code": "207", |
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 shouldn't be 2xx as there is no partial success in this case for the creation of an entity with duplicated attributes.
(NOTE: probably 422 is also wrong as according to "Error Response" rules at https://fiware.github.io/specifications/ngsiv2/stable this is a case in which the error is caused by request itself (i.e. they do not depend on the NGSIv2 server status) so 400 should be used instead. But this is a lateral issue)
Content-Type: application/json | ||
Fiware-Correlator: REGEX([0-9a-f\-]{36}) | ||
Date: REGEX(.*) | ||
|
||
{ | ||
"errorCode": { | ||
"code": "422", | ||
"code": "207", |
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 shouldn't be 2xx as there is no partial success in this case for the update of an entity with duplicated attributes.
(NOTE: probably 422 is also wrong as according to "Error Response" rules at https://fiware.github.io/specifications/ngsiv2/stable this is a case in which the error is caused by request itself (i.e. they do not depend on the NGSIv2 server status) so 400 should be used instead. But this is a lateral issue)
I'm still concerned by the backward compatibility implications of changing a 4xx code to a 2xx. From one 4xx to another 4xx is not a big problem, as the client logic use to deal with 4xx error conditions on the same way. However, fro 4xx to 2xx could break some client response processing logic. Anyway, I propose to add a test to this PR with the following steps in order to gain more insight on this and help us to decide what to do next:
And also this one:
|
Conflicts: CHANGES_NEXT_RELEASE
I have added test case in c585d01 But currently it shows |
Having a look to your implementation, it seems you have just blindly replaced 422 by 207 in all cases. Note that issue #3054 is not about it. Issue #3054 is about the usage of the new code in some circumstances, i.e. when partial success has take place. But if the operation completely fails, then 422 usage has to be kept. Please review implementation to adapt to this behaviour. The tests described my me above should help. |
Sorry for this I haven't understand this issue clearly. Thanks you for your guidance. Now I have reverted the changes in my latest commit 92e0a2b and added code for 207, when partial success has take place. but currently my code is working only in case of Strict append but now working in case of patch/update. I am looking into it and will update the PR soon. |
@fgalan sir, I have tried to implement the code for Could you please provide some suggestion how we can get different HTTP code in both the cases. |
I don't know exactly which difficulties you have, so I can only provide generic advice: follow the code logic during an update operation (a debugger with breadkpoint feature could help, this may be useful), identify the cases of partial updates and implement the desired behaviour without breaking existing functionality (i.e. breaking existing .ftest). |
Seems to me you simply need to set the appropriate value for Look at restReply, a few lines before it ends:
The second parameter to MHD_queue_response is the HTTP status code. Ah, I just checked, HttpStatusCode doesn't support a 207 ...
|
Conflicts: CHANGES_NEXT_RELEASE
Added |
@Anjali-NEC could you tell us the status on this PR? Did you follow my advice above? It would be great to know it, given in the next FIWARE TSC Orion is going to be discussed. |
Currently I am putting this PR on hold as I am busy on another issue. |
@fgalan Please let us know which ticket has high priority to you in below PR: |
These four ones are minor issues. Of course, Orion would be a bit better if they get completed, but they are not actually very important. In this sense, none of them has more priority than other, they can be considered equally minor. On the contrary, I'd suggest to address another more important issues. The important issues are exposed in the Orion roadmap document, which I recommend you to check whenever you consider to pick a new issue. In this sense, these two ones seems to be more appealing that the former four, specially the first one:
Thanks! |
Thanks you for sharing the priority of PRs and also suggesting to work on two issues #3638 and #2389. |
I'm sorry we don't have time to provide feedback on #4149 in a timely manner taking into account the urgency it has for you and that it is not part of the roadmap. Issues that are in the roadmap are the ones in which focus our feedback and review effort. Thus, go ahead with the implementation of #4149 without waiting for our feedback and we will see the PR when it comes. At that moment we have another feedback point. |
Overpassed by PR #4266. |
Fix issue #3054