Skip to content

Make patch_aiobotocore fixture reversible to prevent state leakage#1314

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/sub-pr-1312-again
Draft

Make patch_aiobotocore fixture reversible to prevent state leakage#1314
Copilot wants to merge 7 commits intomainfrom
copilot/sub-pr-1312-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 17, 2026

The patch_aiobotocore session-scoped fixture mutated global state (aiobotocore.endpoint.convert_to_response_dict and aiobotocore.httpchecksum.AioAwsChunkedWrapper attributes) without cleanup, violating fixture teardown best practices.

Changes:

  • Save original function and attributes before mutation
  • Convert fixture to yield-based pattern with teardown
  • Restore original state at session end
@fixture(scope="session", autouse=True)
def patch_aiobotocore():
    # ... setup code ...
    
    # Save originals
    original_convert_to_response_dict = aiobotocore.endpoint.convert_to_response_dict
    saved_attrs = {}
    for attr in ("_make_chunk", "read"):
        if hasattr(aiobotocore.httpchecksum.AioAwsChunkedWrapper, attr):
            saved_attrs[attr] = getattr(aiobotocore.httpchecksum.AioAwsChunkedWrapper, attr)
            delattr(aiobotocore.httpchecksum.AioAwsChunkedWrapper, attr)
    
    yield
    
    # Restore in teardown
    aiobotocore.endpoint.convert_to_response_dict = original_convert_to_response_dict
    for attr, value in saved_attrs.items():
        setattr(aiobotocore.httpchecksum.AioAwsChunkedWrapper, attr, value)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

deepyaman and others added 5 commits February 16, 2026 21:00
Make updates for newer `aiohttp` and `s3fs`.

The `aiobotocore` mock patch was incompatible with `aiohttp` 3.13+ and
`s3fs` 2024.10+. Add no-op `close()`/`release()` to `MockHttpClientResponse`
to avoid `_loop` `AttributeError` on reads, and remove `AioAwsChunkedWrapper`
async overrides so `moto`'s synchronous responses work for writes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
Updated release notes for Kedro-Datasets, including new features, bug fixes, and community contributions.

Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
Copilot AI and others added 2 commits February 17, 2026 05:21
Co-authored-by: deepyaman <14007150+deepyaman@users.noreply.github.com>
Co-authored-by: deepyaman <14007150+deepyaman@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on relaxing gcsfs upper-bound pins Make patch_aiobotocore fixture reversible to prevent state leakage Feb 17, 2026
Copilot AI requested a review from deepyaman February 17, 2026 05:23
Base automatically changed from test/datasets/update-s3-patches to main February 17, 2026 12:33
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.

2 participants