Skip to content

Commit 299b571

Browse files
Fix shared mutable default in BaseBuilder.get_config
Previously, get_configused a mutable default argument for `properties` (i.e. `properties: dict[str, str] = {}`), which caused all instances without an explicit `properties` argument to share the same dictionary. This led to unexpected behavior when one instance modified the dictionary, as changes were reflected across all others and some builders got a wrong value for `jobs`. This commit replaces the default value with `None` and initializes a new dictionary inside the constructor when no value is provided. This ensures each instance has its own independent `properties` dictionary, preventing unintended side effects.
1 parent c3c0602 commit 299b571

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

configuration/builders/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_config(
107107
jobs: int,
108108
next_build: Callable[[Builder, Iterable[BuildRequest]], BuildRequest],
109109
tags: list[str] = [],
110-
properties: dict[str, str] = {},
110+
properties: dict[str, str] = None,
111111
) -> util.BuilderConfig:
112112
"""
113113
Generates a BuilderConfig object for the builder, including worker names,
@@ -133,6 +133,8 @@ def get_config(
133133
"""
134134
# Jobs is mandatory, otherwise builder to worker allocation at runtime cannot be done
135135
assert jobs >= 1, "Jobs must be greater than or equal to 1"
136+
if not properties:
137+
properties = {}
136138
properties["jobs"] = jobs
137139

138140
# Update worker metadata

0 commit comments

Comments
 (0)