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

dropboxQt::files::WriteMode::toJson mis-encodes rev in WriteMode_UPDATE case #6

Open
barbicels opened this issue Jun 30, 2020 · 0 comments

Comments

@barbicels
Copy link

[This appears to be a general problem with stone unions that point to a scalar (string, etc.) rather than a struct or other union; for example, dropboxQt::files::LookupError::toJson has the same issue with the malformed_path scalar. The reason why WriteMode poses a problem, and LookupError does not, is that no-one uses dropboxQt to encode a LookupError, because they only occur in results; WriteMode_UPDATE is unique (I think) in being a non-void union that is used in request parameters, via CommitInfo, in requests such as files/upload.]

While writing code to upload a file to Dropbox using dropboxQt::Files::FilesRoutes::upload, using a WriteMode instance tagged WriteMode_UPDATE in CommitInfo to specify the rev of the existing server copy to be updated, I encountered a couple of issues:

  1. The WriteMode class has no setter for the m_update (rev) member that is required in the WriteMode_UPDATE union. (Creating a derived class WriteModeUpdate seemed like too much work, so, on to Update ApiUtil.h #2.)
  2. I added a setter for its m_update member. Then, when CommitInfo::toJson calls the WriteMode::toJson method, the latter mis-encodes the m_update (rev) value by putting it inside the CommitInfo node as a scalar rather than a tagged node.

This code works for the WriteMode_ADD and WriteMode_OVERWRITE modes only because they are void unions and so it's acceptable to encode mode as a string value inside the CommitInfo node. However, as shown in the Dropbox API v2 Explorer example for files/upload (https://www.dropbox.com/developers/documentation/http/documentation#files-upload), in the WriteMode_UPDATE case, mode has to be a tagged JSON node containing an update (rev) string value. The current dropboxQt code does not produce this; see this screenshot from Qt Creator's debugger, showing the mis-encoded CommitInfo, with an update value beside mode, not inside.

If this were a general stone issue, I would expect it to have been fixed, so could this problem be peculiar to the stone interpreter you used to create dropboxQt?

How should I work around this so that I can program a file upload in WriteMode_UPDATE mode that the server will accept?

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

No branches or pull requests

1 participant