-
Notifications
You must be signed in to change notification settings - Fork 111
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
RpcReply.OK not set correctly due to XML unmarshalling of boolean is broken #34
Comments
I think we can create a custom unmarshaler here. |
Does the RPCReply.Ok flag tell us anything useful? From what I've been able to find the RPCReply is only returned if no error was generated. If something does go wrong, RPCError is raised instead. |
https://www.juniper.net/documentation/en_US/junos/topics/reference/tag-summary/netconf-ok.html "Indicates that the NETCONF server successfully performed a requested operation that changes the state or contents of the device configuration." Using the The
|
Sample of
|
Sample from a lab QFX that had MPLS enabled but not licensed:
|
For me it is more intuitive to check if the response is OK first (the normal flow) rather than if response contains error first (the exception flow). I believe this is another workaround that works but The protocol wrapper should work as stated in the RFC: https://tools.ietf.org/html/rfc6241#page-19 |
Alternate implementation to work around XML unmarshaling limitations in Golang. I'm not a fan of this method since it breaks the API, but I'm providing it for completeness. For my money I'd rather see 8e66346 merged and then have the upstream XML module fixed to add a "flag" field option. closes Juniper#34
I've filed #55 to update documentation so it explains that the Ok flag doesn't mean what one might expect. There are two branches that fix setting the RPCReply.Ok flag processing, but both have drawbacks. I'm open to alternate suggestions for handle the unmarshaling. |
Agreed that it should follow the RFC. We worked on this package through the NANOG hackathon and may have some ideas on unmarshaling it, but still experimenting. |
This should work: https://play.golang.org/p/Qyl_i0Ihf96 @wtucker can you update your code/tests with this method? |
This comment was marked as abuse.
This comment was marked as abuse.
This is fixed in v2. (I understand the xml package so much better than 10 years ago) |
Adds support for returning RPC errors as Go errors. This does it by always returning a list of RPCErrors (even when there is one) and supporting the `Unwrap() []error` implicit interface for `errors` package (Go 1.20 and later)
The following rpc-reply is received:
But the unmarshalled
RpcReply.Ok
did not set totrue
.After checking the unmarshalling format:
the boolean unmarshalling seems to be broken according to the following site
So making the following RPCReply:
and check if
Ok != nil
will make it workThe text was updated successfully, but these errors were encountered: