Skip to content

[Files] Transform string into part for metadata in upload_files request#207

Merged
AMoldova-NI merged 10 commits into
masterfrom
users/amoldova/fix-metadata-field-in-upload-files-request
May 29, 2026
Merged

[Files] Transform string into part for metadata in upload_files request#207
AMoldova-NI merged 10 commits into
masterfrom
users/amoldova/fix-metadata-field-in-upload-files-request

Conversation

@AMoldova-NI
Copy link
Copy Markdown
Contributor

What does this Pull Request accomplish?

Fix upload_files method to accept metadata field with custom data.

Why should this Pull Request be merged?

This fixes a bug issued here #206

What testing has been done?

Testing done using the script provided in the issue

Co-authored-by: Copilot <copilot@github.com>
@AMoldova-NI AMoldova-NI changed the title Transform string into part [Files] Transform string into part for metadata in upload_files request May 11, 2026
@AMoldova-NI AMoldova-NI requested a review from Copilot May 11, 2026 13:09
Copy link
Copy Markdown
Contributor

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

Fixes FileClient.upload_file() multipart encoding so the optional metadata argument is sent as a non-file form part (preventing the File service from rejecting it as a file), addressing the 400 Bad Request described in issue #206.

Changes:

  • Encode metadata as a multipart part tuple (None, json, "application/json") instead of passing a raw JSON string to the multipart Part.
  • Rename the intermediate variable from metadata_str to metadata_part to reflect the new payload shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nisystemlink/clients/file/_file_client.py
Comment thread nisystemlink/clients/file/_file_client.py
Comment thread nisystemlink/clients/file/_file_client.py
Copy link
Copy Markdown
Contributor

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

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

Comment thread nisystemlink/clients/file/_file_client.py Outdated
Comment thread tests/integration/file/test_file_client.py Outdated
Comment thread tests/integration/file/test_file_client.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

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

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

Comment thread tests/integration/file/test_file_client.py Outdated
Comment thread tests/integration/file/test_file_client.py Outdated
Comment thread tests/integration/file/test_file_client.py Outdated
Comment thread tests/integration/file/test_file_client.py Outdated
@AMoldova-NI AMoldova-NI enabled auto-merge (squash) May 26, 2026 12:35
@AMoldova-NI AMoldova-NI disabled auto-merge May 27, 2026 09:55
@AMoldova-NI AMoldova-NI enabled auto-merge (squash) May 27, 2026 09:58
@rbell517 rbell517 closed this May 28, 2026
auto-merge was automatically disabled May 28, 2026 14:38

Pull request was closed

@rbell517 rbell517 reopened this May 28, 2026
@rbell517 rbell517 requested a review from Copilot May 28, 2026 16:08
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

tests/integration/file/test_file_client.py:123

  • test__upload_get_delete_files__succeeds uploads with cleanup=False, but this test no longer deletes the file. Since the test_file fixture only cleans up IDs recorded when cleanup=True, this will leak a file in the integration environment.
    def test__upload_get_delete_files__succeeds(
        self, client: FileClient, test_file, random_filename_extension
    ):
        # upload a file
        file_id = test_file(file_name=random_filename_extension, cleanup=False)
        assert file_id != ""

Comment thread tests/integration/file/test_file_client.py
AMoldova-NI and others added 3 commits May 29, 2026 08:28
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@AMoldova-NI AMoldova-NI reopened this May 29, 2026
…ython into users/amoldova/fix-metadata-field-in-upload-files-request
@AMoldova-NI AMoldova-NI merged commit 0aa5666 into master May 29, 2026
23 of 25 checks passed
@AMoldova-NI AMoldova-NI deleted the users/amoldova/fix-metadata-field-in-upload-files-request branch May 29, 2026 10:31
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.

3 participants