Skip to content
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 unmarshaling: Int32 for Rpc.t, and Base64/Datetime for JSONRPC #182

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

edwintorok
Copy link
Collaborator

All of these work with XMLRPC, but unmarshaling base64 or datetime fails with jsonrpc.

Add some tests to check that all Rpc.t values can be marshaled/unmarshaled.
A more thorough QCheck based test could also be added, but that'll be done in a followup PR.

Rpc.Int32 also fails to be processed by int32_of_rpc. This value isn't actually created anywhere in this library, but XAPI uses it for backwards compatibility reasons in its Events code (to emit an XmlRPC i4), and then adding a fastpath to the event code that passes Rpc.t internally fails because it cannot be converted back. I've got a workaround for that in XAPI, but we should also fix it here.

Draft PR, because this requires some internal testing with XAPI too.

Rpc.Int32 is never created by this library,
but XAPI does create it for backwards compatibility
with its XMLRPC events protocol.

Using either JSONRPC or XMLRPC to marshal/unmarshal works,
but passing an Rpc.t directly fails.

Signed-off-by: Edwin Török <[email protected]>
JSONRPC marshals these as string, but then trying to unmarshal would raise an exception.
We need to accept String when unmarshaling DateTime and Base64 too.

Some type safety is lost, because JSON doesn't have a way to distinguish between these (XMLRPC does).

Update the unit test to check that this now works.

Signed-off-by: Edwin Török <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants