Skip to content

FsspecStore.from_mapper() fails with DefaultAzureCredential because AzureBlobFileSystem is not JSON serializable #4220

Description

@hginzel

Zarr version

v3.3.0

Numcodecs version

v0.6.15

Python Version

3.12.11

Operating System

Ubuntu 26.04

Installation

uv add zarr

Environment

  • Python 3.12.11
  • zarr 3.3.0
  • xarray 2026.7.0
  • fsspec 2026.7.0
  • adlfs 2026.5.0
  • azure-identity 1.25.3

Description

Opening an xarray dataset backed by an Azure Blob Storage FSMap created with
DefaultAzureCredential fails because FsspecStore.from_mapper() attempts to
serialize the filesystem using fs.to_json().

The embedded DefaultAzureCredential is not JSON serializable.

Steps to reproduce

# /// script
# requires-python = ">=3.12"
# dependencies = [
#   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues

import zarr
from fsspec import filesystem
from azure.identity import DefaultAzureCredential
import xarray as xr

fs = filesystem(
    "az",
    account_name="<account>",
    credential=DefaultAzureCredential(),
)
mapper = fs.get_mapper("container/example.zarr")
xr.open_zarr(mapper)

# zarr.print_debug_info()

Additional output

Traceback

TypeError: Object of type DefaultAzureCredential is not JSON serializable

The traceback ends in
FsspecStore.from_mapper(...)
_make_async(...)
fs.to_json()
json.dumps(...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions