Skip to content

add check for blob access#133

Open
ryanraaschCDC wants to merge 6 commits into
mainfrom
111-no-access-warning
Open

add check for blob access#133
ryanraaschCDC wants to merge 6 commits into
mainfrom
111-no-access-warning

Conversation

@ryanraaschCDC

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds explicit Blob Storage access verification to BlobEndpoint so common Blob operations fail early with clearer, contextualized errors, and updates typing stubs plus introduces a new test module for the access-check behavior.

Changes:

  • Add BlobEndpoint.check_blob_access() / BlobEndpoint.verify_blob_access() and call verification before write_blob, read_blobs, read_csv, and get_versions.
  • Update generated and template .pyi stubs to include the new methods.
  • Add pytest coverage for access-check behavior and for access-check gating on several BlobEndpoint methods.

Reviewed changes

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

File Description
cfa/dataops/catalog.py Implements access check/verification and gates key blob operations behind verify_blob_access().
tests/test_blob_access_check.py Adds tests for the new access-check APIs and for method-level access gating (but currently mocks the wrong call path).
typings/cfa/dataops/catalog.pyi Adds the new methods to the published typing stubs.
cfa/dataops/stub_templates/catalog.pyi.mako Adds the new methods to the stub generation template to keep stubs in sync.
Comments suppressed due to low confidence (5)

tests/test_blob_access_check.py:43

  • check_blob_access() branches on HttpResponseError (status_code==401) raised from get_container_properties(); patching walk_blobs_in_container and raising a generic Exception with status_code won’t be caught by the intended handler. Mock BlobServiceClient.get_container_properties to raise an HttpResponseError (or subclass) with status_code=401.
    def test_check_blob_access_401_unauthorized(self, blob_endpoint):
        class Err401(Exception):
            status_code = 401

        with patch(

tests/test_blob_access_check.py:57

  • Same as the 401 case: the implementation catches HttpResponseError and checks status_code==403. This test currently patches the wrong function and raises an exception type that won’t be handled as expected.
    def test_check_blob_access_403_forbidden(self, blob_endpoint):
        class Err403(Exception):
            status_code = 403

        with patch(

tests/test_blob_access_check.py:71

  • check_blob_access() handles missing containers via ResourceNotFoundError from get_container_properties(); patching walk_blobs_in_container and raising a custom Exception won’t hit that branch.
    def test_check_blob_access_resource_not_found(self, blob_endpoint):
        class Err404(Exception):
            status_code = 404

        with patch(

tests/test_blob_access_check.py:87

  • The 'Authentication failed' branch is only reached when ClientAuthenticationError is raised by get_container_properties(). Raising a generic Exception will hit the fallback 'Failed to verify access…' branch instead, making this assertion fail.
    def test_check_blob_access_authentication_error(self, blob_endpoint):
        with patch(
            "cfa.dataops.catalog.walk_blobs_in_container",
            side_effect=Exception("credential unavailable"),
        ):
            has_access, message = blob_endpoint.check_blob_access()

tests/test_blob_access_check.py:97

  • check_blob_access() does not call walk_blobs_in_container, so this test will currently attempt a real get_container_properties() call. Mock BlobServiceClient.get_container_properties to raise the generic exception so the fallback branch is exercised without network access.
    def test_check_blob_access_generic_exception(self, blob_endpoint):
        with patch(
            "cfa.dataops.catalog.walk_blobs_in_container",
            side_effect=Exception("Something went wrong"),
        ):
            has_access, message = blob_endpoint.check_blob_access()


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

Comment thread tests/test_blob_access_check.py
Comment thread tests/test_blob_access_check.py Outdated
ryanraaschCDC and others added 5 commits July 24, 2026 12:02
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

better warning when no access to blob containers

3 participants