-
Notifications
You must be signed in to change notification settings - Fork 15
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
(RESTCONF+YANG) PUT Request with invalid JSON modifies state #100
Comments
Main root of a problem is solved in #101 PR, but IMO, |
Sorry, I have to reopen this issue.
I have time to do this but I need an advice how. Core of a problem is in this function: Line 470 in fe20e07
It modifies tree in 2 steps: Many thanks. |
As it exists today FreeCONF's operations happen on the live objects. I think to achieve what you are looking for freeconf should support "data stores" that act as sandbox to validate requests and only after no errors are found, then reapply the request to the live objects. |
When making CRUD request (PUT) to RESTCONF with invalid JSON (missing bracket for ex), request is rejected with proper error message but state is also changed. I found core of a problem, but don't have proper solution.
IMO problem lays between these 3 functions:
yang/nodeutil/json_rdr.go
Line 21 in fe20e07
Here function returns
node.Node
(which can benode.ErrorNode
in case of read errors) without separate error value.This cause code in
restconf
:https://github.com/freeconf/restconf/blob/72cc856c177bf129d9c55bb2978367379209b4c6/browser_handler.go#L179-L184
to not to check error and pass erroneous
node.Node
right toyang
library.Here,
ReplaceFrom
first deletes previous version of element before trying to apply new version which is an just error.yang/node/selection.go
Line 470 in fe20e07
The error is returned but it's too late, data is already gone.
Like I said, I've done investigation :) but I don't know how to properly fix this issue to keep code consistency.
Main question is: what is better, to return error from
ReadJSONIO()
or to check fornode.ErrorNode
in browser_handler.go?The text was updated successfully, but these errors were encountered: