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

createAttachmentOrder with meta #282

Closed
gcandal opened this issue Jun 8, 2021 · 8 comments
Closed

createAttachmentOrder with meta #282

gcandal opened this issue Jun 8, 2021 · 8 comments
Assignees
Labels
core 💎 Issue belongs to the core development context enhancement New feature or request feature-request 💡 Request the addition of a feature risky ❕ Seems to be risky unit-testing Issue requires creation of unit tests

Comments

@gcandal
Copy link
Contributor

gcandal commented Jun 8, 2021

Rationale

The creation of order attachments expects a file and a meta dictionary (see https://github.com/ripe-tech/ripe-core/blob/ba23882efa65acb165e924c6f836c6933646604f/src/ripe_core/controllers/api/order.py#L97).

However, the current SDK implementation of the endpoint doesn't support meta (see

dataM: {
).

Description

The implementation of the rationale above could probably be similar to:

    options = Object.assign(options, {
        url: url,
        method: "POST",
        dataM: {
            file: file,
            meta: JSON.stringify(meta)
        },
        auth: true
    });

But unless I'm missing something obvious, ripe-sdk doesn't support strings as values when using a multipart payload dataM (see

ripe.Ripe.prototype._encodeMultipart = function(fields, mime = null, doseq = false) {
).

Trying to use them results in RangeError: offset is out of bounds because the string is not being encoded, resulting in this:

image

Related: https://github.com/ripe-tech/ripe-core/pull/4564

@gcandal gcandal added enhancement New feature or request triage Issue currently under triage feature-request 💡 Request the addition of a feature labels Jun 8, 2021
@ripe-tobias-bot

This comment has been minimized.

@joamag
Copy link
Contributor

joamag commented Jun 8, 2021

The suggested implementation does not work... if working with multipart you cannot pass dictionaries

@gcandal
Copy link
Contributor Author

gcandal commented Jun 8, 2021

You mean dictionaries as values? I didn't, I used a string.

@joamag
Copy link
Contributor

joamag commented Jun 8, 2021

yes, but on the server-side you'll not be able to de-serialize them automatically, so no good to pass JSON.dumps

@joamag
Copy link
Contributor

joamag commented Jun 8, 2021

You need to use something like meta in the order POST... and still the multi-part issue with strings (in the SDK) would have to be fixed

@joamag joamag added the risky ❕ Seems to be risky label Jun 8, 2021
@joamag
Copy link
Contributor

joamag commented Jun 8, 2021

ok maybe I'm wrong and now we support automatic JSON casting in Appier... Go ahead and try to see what's wrong with the multi-part encoding... But check the appier and yonius implementations as the multipart encoder should be aligned with both

Screenshot 2021-06-08 at 11 40 19

@joamag joamag assigned gcandal and unassigned joamag Jun 8, 2021
@joamag joamag added core 💎 Issue belongs to the core development context unit-testing Issue requires creation of unit tests labels Jun 8, 2021
@joamag
Copy link
Contributor

joamag commented Jun 8, 2021

@gcandal let's also create some unit tests to avoid regression for this mixed types multipart situation

@joamag joamag removed the triage Issue currently under triage label Jun 8, 2021
@gcandal
Copy link
Contributor Author

gcandal commented Jun 29, 2021

Requires hivesolutions/appier#47

@gcandal gcandal closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core 💎 Issue belongs to the core development context enhancement New feature or request feature-request 💡 Request the addition of a feature risky ❕ Seems to be risky unit-testing Issue requires creation of unit tests
Projects
None yet
Development

No branches or pull requests

2 participants