From 4cf0c8fd9f910842dac6f2a1ae0b10f72e6ce960 Mon Sep 17 00:00:00 2001 From: matthiasL-scality Date: Wed, 30 Sep 2026 09:50:33 +0000 Subject: [PATCH] fix: avoid shared mutable default args in GitHost helpers GitHubClient._get() mutates the headers dict it receives (kwargs.setdefault('headers', {}).update(...)). Since GitHostObject.get() and list() defaulted to a single shared headers={} dict, conditional request headers (If-None-Match / If-Modified-Since) were written into state shared across every call and thread. Default to None and build a fresh dict per call. Co-Authored-By: Claude Sonnet 5.5 --- bert_e/git_host/base.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bert_e/git_host/base.py b/bert_e/git_host/base.py index a38ab926..18c97201 100644 --- a/bert_e/git_host/base.py +++ b/bert_e/git_host/base.py @@ -115,7 +115,8 @@ def __init__(self, client=None, _validate=True, **data): self.data = data @classmethod - def get(cls, client, url=None, params={}, headers={}, **kwargs): + def get(cls, client, url=None, params=None, headers=None, + **kwargs): """Get a Githost object. The result is parsed using cls.GET_SCHEMA, of cls.SCHEMA if absent. @@ -129,6 +130,8 @@ def get(cls, client, url=None, params={}, headers={}, **kwargs): Returns: The result of the query, parsed by the shema. """ + params = {} if params is None else params + headers = {} if headers is None else headers url = url or cls.GET_URL if url is None: raise InvalidOperation( @@ -141,7 +144,8 @@ def get(cls, client, url=None, params={}, headers={}, **kwargs): return obj @classmethod - def list(cls, client, url=None, params={}, headers={}, **kwargs): + def list(cls, client, url=None, params=None, headers=None, + **kwargs): """List objects. The result is parsed using cls.LIST_SCHEMA, or cls.GET_SCHEMA if @@ -154,6 +158,8 @@ def list(cls, client, url=None, params={}, headers={}, **kwargs): The elements of the response as they are parsed by the schema. """ + params = {} if params is None else params + headers = {} if headers is None else headers url = url or cls.LIST_URL if url is None: raise InvalidOperation( @@ -180,8 +186,9 @@ def load(cls, data, schema_cls=None, **kwargs): return cls(**load_schema(schema_cls, data, **kwargs), _validate=False) @classmethod - def create(cls, client, data, headers={}, url=None, **kwargs): + def create(cls, client, data, headers=None, url=None, **kwargs): """Create an object.""" + headers = {} if headers is None else headers url = url or cls.CREATE_URL if url is None: raise InvalidOperation( @@ -196,8 +203,9 @@ def create(cls, client, data, headers={}, url=None, **kwargs): return obj @classmethod - def update(cls, client, data, headers={}, url=None, **kwargs): + def update(cls, client, data, headers=None, url=None, **kwargs): """Update an object.""" + headers = {} if headers is None else headers url = url or cls.UPDATE_URL or cls.GET_URL if url is None: raise InvalidOperation(