Skip to content

Conversation

@julien-lang
Copy link
Contributor

WIP

Copy link
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

This PR addresses improvements related to SG-38959, focusing on upload request handling, URL sanitization, and documentation updates. The changes simplify HTTP error handling, introduce a utility for safe URL logging, and improve the clarity of logging configuration examples.

Key Changes:

  • Simplified HTTP error handling in upload requests by removing redundant try-except block
  • Added safe_short_url() utility function to sanitize URLs in logs by removing credentials and truncating long paths
  • Updated logging documentation with clearer examples showing proper logger configuration

Reviewed Changes

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

File Description
shotgun_api3/shotgun.py Simplified _make_upload_request() error handling, refactored request creation to use modern syntax, added safe_short_url() utility for sanitizing URLs in logs, and included debug code/TODOs for testing
tests/test_client.py Added TODO comments for future test coverage improvements
docs/cookbook/usage_tips.rst Improved logging configuration examples with proper logger setup and consistent string quotes

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

Comment on lines 4345 to 4346
storage_url = "https://wrong.host.badssl.com/"

Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

Debug code is overwriting the storage_url parameter, which will break file uploads to production storage. This code must be removed before merging.

Suggested change
storage_url = "https://wrong.host.badssl.com/"

Copilot uses AI. Check for mistakes.
:param int size: Number of bytes in the data stream.
:param str storage_url: Target URL for the uploaded file.
:returns: upload url.
:returns: upload url - NO! Return the AWS object ID.
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The return value description is unclear and contains an editorial comment ('NO!'). Update this to clearly document what is actually returned by the function.

Suggested change
:returns: upload url - NO! Return the AWS object ID.
:returns: The AWS object ID (ETag) for the uploaded part.

Copilot uses AI. Check for mistakes.
:rtype: str
"""

## TODO - add unitests for those cases
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'unitests' to 'unit tests'.

Suggested change
## TODO - add unitests for those cases
## TODO - add unit tests for those cases

Copilot uses AI. Check for mistakes.
LOG.debug("Completed request to %s" % request.get_method())
LOG.debug(f"Completed request to {safe_short_url(storage_url)}")

# FIXME - why don't we capture SSL errors here?
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

This FIXME indicates incomplete error handling logic. SSL errors should either be explicitly handled or the comment should be addressed before merging.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant