Skip to content

Conversation

@JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Sep 18, 2025

In #34, it became apparent that CI tests were failing due to mismatched directoryLabel values. This issue is specific to the current develop branch of Dataverse, which the CI container is using, and will also affect the upcoming 6.8 version. At its core, the upcoming Dataverse version 6.8 introduces a behavior where empty metadata keys passed in the JSON string result in the removal of existing metadata (see IQSS/dataverse#11439). The current implementation of python-dvuploader defaults directoryLabel to an empty string, leading to the removal of the directoryLabel and causing a mismatch in the tests.

This pull request addresses these issues by modifying the file metadata construction for upload requests and improving error messaging in integration tests. The primary changes include making the directoryLabel field conditional, streamlining error handling, and enhancing test assertion messages for clarity.

Metadata handling improvements:

  • Updated the _get_json_data function in dvuploader/nativeupload.py to only include the directoryLabel field in the metadata dictionary if the file actually has a directory_label value, ensuring cleaner and more accurate upload requests.

Error handling and messaging:

  • Removed unnecessary printing of the response JSON in the error handling path of _update_single_metadata, streamlining error management.

Test assertion improvements:

  • Enhanced assertion messages in test_native_upload_by_handler in tests/integration/test_native_upload.py to include more descriptive information and pretty-printed JSON, making test failures easier to diagnose.

Only include 'directoryLabel' in metadata if present, improving flexibility for file uploads. Also remove unnecessary print statement from error handling in _update_single_metadata.
Enhanced the clarity of assertion error messages in TestNativeUpload by including expected values and pretty-printing file details for easier debugging.
@JR-1991 JR-1991 requested a review from Copilot September 18, 2025 21:03
@JR-1991 JR-1991 self-assigned this Sep 18, 2025
@JR-1991 JR-1991 added the bug Something isn't working label Sep 18, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where empty directoryLabel values cause directory labels to be removed in Dataverse 6.8, which treats empty metadata keys as removal requests. The fix ensures only non-empty directory labels are included in upload metadata.

  • Modified metadata construction to conditionally include directoryLabel only when the value exists
  • Removed unnecessary response printing in error handling
  • Enhanced test assertion messages with better formatting and more descriptive error information

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dvuploader/nativeupload.py Updated _get_json_data to conditionally include directoryLabel and removed debug print in error handling
tests/integration/test_native_upload.py Enhanced assertion error messages with better formatting and more descriptive content

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Changed the URL in test_raise_http_error from example.com to demo.dataverse.org to better reflect a realistic test scenario.
@JR-1991 JR-1991 merged commit 9ad752c into main Sep 18, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from Ready for Review to Done in PyDataverse Working Group Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

2 participants