Repository navigation
Fix prepare_body stream detection for __getattr__-based file wrappers - #7433
Conversation
|
Hi @k223kim, This PR has quite a few oddities in it, did you happen to use an LLM to generate it? There are unrelated tests and the change itself is wrong (at least for the issue you reported). |
|
Hey @nateprewitt , thanks for the review! |
|
Perhaps - I can be more precise with the if-statement and just restoring it to If this sounds better, happy to adjust test accordingly. |
|
Yep, it should be The tests are engraining a lot of tqdm/use case specific semantics into the test suite that I'm not sure we want. While this may work, I don't really want to call it a "supported pattern" because that tends to lead to other areas that didn't support this before getting PRs to "fix" support. I think it's unlikely this changes again in the future, the def test_getattr_proxy_stream_follows_redirect(self, httpbin):
"""Ensure stream wrappers that don't implement __iter__ directly are still detected."""
class AttrProxy:
def __init__(self):
self._file = io.BytesIO(b"data")
def __getattr__(self, name):
return getattr(self._file, name)
r = requests.post(httpbin("redirect-to?url=/post&status_code=307"), data=AttrProxy())
assert r.json()["data"] == "data" |
|
@nateprewitt Makes sense. Adjusted the PR 😄 Would appreciate it if you can take a look! |
nateprewitt
left a comment
There was a problem hiding this comment.
One minor tweak for readability, but otherwise this looks good. Thanks @k223kim!
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | Type | Update | |---|---|---|---|---|---| | [boto3](https://github.com/boto/boto3) | `>=1.43.6` → `>=1.43.7` |  |  | project.dependencies | patch | | [docker/dockerfile](https://github.com/moby/buildkit) | `1.23` → `1.24` |  |  | syntax | minor | | [ghcr.io/getarcaneapp/arcane](https://github.com/getarcaneapp/arcane) | `v1.19.0` → `v1.19.1` |  |  | | patch | | [n8nio/n8n](https://n8n.io) ([source](https://github.com/n8n-io/n8n)) | `2.21.0` → `2.21.1` |  |  | | patch | | nginx | `1.30-alpine3.23` → `1.31-alpine3.23` |  |  | final | minor | | nginx | `1.30-alpine` → `1.31-alpine` |  |  | final | minor | | [paramiko](https://github.com/paramiko/paramiko) ([changelog](https://www.paramiko.org/changelog.html)) | `>=3.5.1` → `>=4.0.0` |  |  | project.dependencies | patch | | [pymdown-extensions](https://github.com/facelessuser/pymdown-extensions) | `>=10.21.2` → `>=10.21.3` |  |  | project.dependencies | patch | | [pytest](https://github.com/pytest-dev/pytest) ([changelog](https://docs.pytest.org/en/stable/changelog.html)) | `>=8.4.2` → `>=9.0.3` |  |  | project.optional-dependencies | patch | | [pytest-cov](https://github.com/pytest-dev/pytest-cov) ([changelog](https://pytest-cov.readthedocs.io/en/latest/changelog.html)) | `>=6.3.0` → `>=7.1.0` |  |  | project.optional-dependencies | patch | | [python](https://python.org) ([source](https://github.com/python/cpython)) | `>=3.14.4` → `>=3.14.5` |  |  | requires-python | patch | | [random](https://registry.terraform.io/providers/hashicorp/random) ([source](https://github.com/hashicorp/terraform-provider-random)) | `3.8.1` → `3.9.0` |  |  | required_provider | minor | | renovate/renovate | `bf5338a` → `ee31283` | | | container | digest | | [requests](https://github.com/psf/requests) ([changelog](https://github.com/psf/requests/blob/master/HISTORY.md)) | `>=2.34.0` → `>=2.34.1` |  |  | project.dependencies | patch | | [time](https://registry.terraform.io/providers/hashicorp/time) ([source](https://github.com/hashicorp/terraform-provider-time)) | `~> 0.13` → `~> 0.14` |  |  | required_provider | minor | | [tls](https://registry.terraform.io/providers/hashicorp/tls) ([source](https://github.com/hashicorp/terraform-provider-tls)) | `4.2.1` → `4.3.0` |  |  | required_provider | minor | This PR was automatically generated by Renovate Bot. Please review the changes before merging. --- ### Release Notes <details> <summary>boto/boto3 (boto3)</summary> ### [`v1.43.7`](https://github.com/boto/boto3/blob/HEAD/CHANGELOG.rst#1437) [Compare Source](boto/boto3@1.43.6...1.43.7) \====== - api-change:`arc-region-switch`: \[`botocore`] Adds support for enabling and disabling Lambda event source mappings in Region switch plans. - api-change:`batch`: \[`botocore`] Adds a billing callout to docs regarding using the CE Scale Down Delay feature - api-change:`bedrock-agentcore-control`: \[`botocore`] Adds support for read-only summary APIs for Policy Engine, Policy, and Policy Generation resources, enabling metadata retrieval without KMS decryption for AWS Config integration. - api-change:`billingconductor`: \[`botocore`] Add ConflictException to UpdateCustomLineItem operation. - api-change:`connect`: \[`botocore`] This change added three new EventSourceName for schedule notification feature - api-change:`connectcampaignsv2`: \[`botocore`] This release added support for Outbound Campaign timezone detection using all available contact methods - api-change:`connectcases`: \[`botocore`] Amazon Connect Cases now supports SLA durations of up to 2 years (1,051,200 minutes), increased from the previous maximum of 90 days (129,600 minutes). This enables you to track long-running service level agreements for cases that require extended resolution timelines. - api-change:`dsql`: \[`botocore`] Added support for Amazon Aurora DSQL change data capture (CDC) streams that deliver row-level database changes to Amazon Kinesis in JSON format. Includes CreateStream, GetStream, ListStreams, and DeleteStream operations. - api-change:`ec2`: \[`botocore`] Include length limits in the SDK and documentation for text fields in Image (AMI) APIs such as the image name and description - api-change:`endpoint-rules`: \[`botocore`] Update endpoint-rules client to latest version - api-change:`es`: \[`botocore`] Adds support for AutomatedSnapshotPauseOptions. - api-change:`glue`: \[`botocore`] AWS Glue now defaults the job timeout to 480 minutes for Glue version 5.0 and later when no timeout value is specified. The default remains 2,880 minutes for Glue version 4.0 and earlier. - api-change:`lightsail`: \[`botocore`] Added OriginIpAddressTypeEnum (ipv4, ipv6, dualstack) and ipAddressType field to Origin and InputOrigin structures for Lightsail CDN distributions. Allows customers to specify how the distribution connects to origins, using IPv4, IPv6, or dualstack networking - api-change:`opensearch`: \[`botocore`] Adds support for AutomatedSnapshotPauseOptions. - api-change:`partnercentral-account`: \[`botocore`] Added ServiceQuotaExceededExceptions for Profile operations - api-change:`pcs`: \[`botocore`] Add support for Amazon EC2 Interruptible-ODCR - api-change:`quicksight`: \[`botocore`] Adds five new custom permission option for Quick Apps so that these capabilities can be controlled by public SDK and CLI. - api-change:`redshift`: \[`botocore`] Added rg.xlarge and rg.4xlarge to valid NodeType values and updated documentation for CreateCluster, ModifyCluster, ResizeCluster, and RestoreFromClusterSnapshot APIs to reflect RG node type support. - api-change:`rtbfabric`: \[`botocore`] Customers can now configure custom domain names for their RTB Fabric gateways. This enables partners to use their own branded domain for RTB traffic instead of the default rtbfabric endpoint - api-change:`sagemaker`: \[`botocore`] Adds execution role session name mode to reflect user identity in Studio. Adds Flexible Training Plans on Studio apps. Adds restricted model packages to control access to proprietary model artifacts via IAM. Fixed instance type parity between inference endpoints and managed shadow tests. - api-change:`securityagent`: \[`botocore`] Add support for code reviews, a new resource type that enables automated security-focused static analysis of source code repositories. - api-change:`socialmessaging`: \[`botocore`] Adds parameters to call the GetWhatsAppMessageTemplate and UpdateWhatsAppMessageTemplate APIs with a template name and language code in place of the template ID. Linked WhatsApp accounts also describe whether the WABA is onboarded to Meta's Marketing Messages API. - api-change:`stepfunctions`: \[`botocore`] Updated default SDK endpoints for AWS Step Functions in AWS GovCloud (US) regions. The default Dual-Stack endpoints now resolve to "states-fips" prefixed hostnames. There are no changes to service behavior. No customer action is required. </details> <details> <summary>getarcaneapp/arcane (ghcr.io/getarcaneapp/arcane)</summary> ### [`v1.19.1`](https://github.com/getarcaneapp/arcane/blob/HEAD/CHANGELOG.md#v1191) [Compare Source](getarcaneapp/arcane@v1.19.0...v1.19.1) ##### Bug fixes - show archived switch overlapping projects search bar([d02a05c](getarcaneapp/arcane@d02a05c) by [@​kmendell](https://github.com/kmendell)) - show correct environments types in filter ([#​2578](getarcaneapp/arcane#2578) by [@​kmendell](https://github.com/kmendell)) - build history not being updated after builds are completed ([#​2586](getarcaneapp/arcane#2586) by [@​kmendell](https://github.com/kmendell)) - incorrect backend arg used for trivy on 32bit hosts ([#​2587](getarcaneapp/arcane#2587) by [@​kmendell](https://github.com/kmendell)) - updater api authorization checks ([#​2588](getarcaneapp/arcane#2588) by [@​kmendell](https://github.com/kmendell)) - deny non hmac jwt requests([d568d03](getarcaneapp/arcane@d568d03) by [@​kmendell](https://github.com/kmendell)) - add rate limiting to webhooks and auth endpoints, and add caching to user session ([#​2591](getarcaneapp/arcane#2591) by [@​kmendell](https://github.com/kmendell)) ##### Other - add mobile device custom redirect url for oidc ([#​2580](getarcaneapp/arcane#2580) by [@​kmendell](https://github.com/kmendell)) - migrate off gin to use echo for backend router ([#​2582](getarcaneapp/arcane#2582) by [@​kmendell](https://github.com/kmendell)) - store user sessions in database with proper jti ([#​2590](getarcaneapp/arcane#2590) by [@​kmendell](https://github.com/kmendell)) **Full Changelog**: <getarcaneapp/arcane@v1.19.0...v1.19.1> </details> <details> <summary>facelessuser/pymdown-extensions (pymdown-extensions)</summary> ### [`v10.21.3`](https://github.com/facelessuser/pymdown-extensions/releases/tag/10.21.3) [Compare Source](facelessuser/pymdown-extensions@10.21.2...10.21.3) #### 10.21.3 - **FIX**: Fix regression that allows a snippet to be loaded outside of the base path using directory traversal when `restrict_base_path` is enabled (the default). Found by [@​gistrec](https://github.com/gistrec). </details> <details> <summary>python/cpython (python)</summary> ### [`v3.14.5`](python/cpython@v3.14.4...v3.14.5) [Compare Source](python/cpython@v3.14.4...v3.14.5) </details> <details> <summary>hashicorp/terraform-provider-random (random)</summary> ### [`v3.9.0`](https://github.com/hashicorp/terraform-provider-random/blob/HEAD/CHANGELOG.md#390-May-12-2026) [Compare Source](hashicorp/terraform-provider-random@v3.8.1...v3.9.0) FEATURES: - resource/random\_bytes: add ephemeral random\_bytes resource ([#​711](hashicorp/terraform-provider-random#711)) ENHANCEMENTS: - Added linux/s390x build target for IBM Z platform support ([#​784](hashicorp/terraform-provider-random#784)) BUG FIXES: - resource/random\_password, resource/random\_string: Fix UTF-8 character handling to correctly count characters instead of bytes when using multi-byte UTF-8 characters in override\_special ([#​741](hashicorp/terraform-provider-random#741)) </details> <details> <summary>psf/requests (requests)</summary> ### [`v2.34.1`](https://github.com/psf/requests/blob/HEAD/HISTORY.md#2341-2026-05-13) [Compare Source](psf/requests@v2.34.0...v2.34.1) **Bugfixes** - Widened `json` input type from `dict` and `list` to `Mapping` and `Sequence`. ([#​7436](psf/requests#7436)) - Changed `headers` input type to MutableMapping and removed `None` from `Request.headers` typing to improve handling for users. ([#​7431](psf/requests#7431)) - `Response.reason` moved from `str | None` to `str` to improve handling for users. ([#​7437](psf/requests#7437)) - Fixed a bug where some bodies with custom `__getattr__` implementations weren't being properly detected as Iterables. ([#​7433](psf/requests#7433)) </details> <details> <summary>hashicorp/terraform-provider-time (time)</summary> ### [`v0.14.0`](https://github.com/hashicorp/terraform-provider-time/blob/HEAD/CHANGELOG.md#0140-May-12-2026) [Compare Source](hashicorp/terraform-provider-time@v0.13.1...v0.14.0) ENHANCEMENTS: - Added linux/s390x build target for IBM Z platform support ([#​486](hashicorp/terraform-provider-time#486)) </details> <details> <summary>hashicorp/terraform-provider-tls (tls)</summary> ### [`v4.3.0`](https://github.com/hashicorp/terraform-provider-tls/blob/HEAD/CHANGELOG.md#430-May-12-2026) [Compare Source](hashicorp/terraform-provider-tls@v4.2.1...v4.3.0) ENHANCEMENTS: - Added linux/s390x build target for IBM Z platform support ([#​771](hashicorp/terraform-provider-tls#771)) </details> --- ### Configuration 📅 **Schedule**: (in timezone America/Toronto) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzYuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE3Ni4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=--> --------- Co-authored-by: Mamadou Yaya DIALLO <5+mombe090@noreply.gitea.prod.home.mombesoft.com> Co-authored-by: Renovate Bot <renovate@mombesoft.com> Reviewed-on: https://gitea.prod.home.mombesoft.com/homelab/craftarc/pulls/434 Co-authored-by: Renovate Bot <6+renovatebot@noreply.gitea.prod.home.mombesoft.com> Co-committed-by: Renovate Bot <6+renovatebot@noreply.gitea.prod.home.mombesoft.com>
Resolves #7432 .
Add
hasattr(data, "__iter__")as a fallback stream detector:This catches file-like objects that proxy their interface through
__getattr__, restoring the 2.33.1 behavior without reverting the isinstance(Iterable) modernization for standard iterables.