Skip to content

Commit

Permalink
params: deepcopy service config dicts to avoid mutation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zzacharo committed Sep 28, 2023
1 parent 3f188b7 commit 1a51430
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion invenio_records_resources/services/records/params/facets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

"""Facets parameter interpreter API."""

from copy import deepcopy

from ..facets import FacetsResponse
from .base import ParamInterpreter
Expand All @@ -26,7 +27,7 @@ def __init__(self, config):
@property
def facets(self):
"""Get the defined facets."""
return self.config.facets
return deepcopy(self.config.facets)

def add_filter(self, name, values):
"""Add a filter for a facet."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

"""Pagination parameter interpreter API."""

from copy import deepcopy

from ....pagination import Pagination
from ...errors import QuerystringValidationError
from .base import ParamInterpreter
Expand All @@ -18,7 +20,7 @@ class PaginationParam(ParamInterpreter):

def apply(self, identity, search, params):
"""Evaluate the query str on the search."""
options = self.config.pagination_options
options = deepcopy(self.config.pagination_options)

default_size = options["default_results_per_page"]

Expand Down

0 comments on commit 1a51430

Please sign in to comment.