-
Notifications
You must be signed in to change notification settings - Fork 46
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 jsonData
not passed correctly
#203
Conversation
I can confirm that this change makes the previously failing test in |
Nice work, @JR-1991! |
Please note @adswa's changes in datalad/datalad-dataverse#322 and my alternative fix in #207, which is a PR onto this branch, not the main branch. |
Fix handling of empty metadata when uploading data files
@shoeffner, thanks for the notice and the PR! Once I return from vacation, I will add a test to check for empty |
I've included a test case to verify whether the behavior is as expected when |
@shoeffner are you interested in "triage" access? I just sent you an invite. You should see it at https://github.com/gdcc 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't run the tests, so I trust you that it works :) The CI did, though, so this looks good!
This looks good and I just added a few comments as food for thought here and there. In general, I would merge it and then see what we can do in #189 to improve further.
Right now, this looks like a very good fix for the problem at hand.
Thanks!
@shoeffner I have updated this PR and specifically the tests to use pyDataverse methods instead of manual requests, as highlighted by you. The PR is now ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test this but tests are passing (and there are lots of new tests!) and the code makes sense.
Sorry for not responding earlier, but it looks good and I am happy it got merged! |
Overview
This PR addresses the issue reported at datalad/datalad-dataverse#320, where metadata sent via NativeApi.replace_datafile wasn’t updating the file metadata correctly. The problem arose because the jsonData payload needs to be sent as form-data, which HTTPX’s json kwarg doesn’t handle properly.
The fix involves sending the payload via the data argument. However, since other endpoints require data to be sent through the json argument, this PR introduces a private method in api.py to determine the correct way to send the data. This method checks for the presence of the jsonData key and adjusts the argument accordingly. If the key isn’t found, the json argument is used by default.
To prevent similar issues in the future, the tests have been updated. The replace_datafile tests now ensure that the metadata is correctly updated.
TLDR
jsonData
key is present sent throughdata
kwargjson