Skip to content

Fix issue when resetting config after new value has been added #1068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ endif::[]
* Fix for Starlette/FastAPI to correctly capture request bodies as strings {pull}1042[#1041]
* Fix transaction names for Starlette Mount routes {pull}1037[#1037]
* Fix for elastic excepthook arguments {pull}1050[#1050]
* Fix issue with remote configuration when resetting config values {pull}1068[#1068]


[[release-notes-6.x]]
Expand Down
2 changes: 1 addition & 1 deletion elasticapm/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def reset(self):
"""
callbacks = []
for key in compat.iterkeys(self._config.values):
if self._config.values[key] != self._first_config.values[key]:
if key in self._first_config.values and self._config.values[key] != self._first_config.values[key]:
callbacks.append((key, self._config.values[key], self._first_config.values[key]))

with self._lock:
Expand Down
13 changes: 13 additions & 0 deletions tests/config/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,19 @@ class MyConfig(_ConfigBase):
assert test_var["foo"] == 3


def test_reset_after_adding_config():
class MyConfig(_ConfigBase):
foo = _ConfigValue("foo")
bar = _ConfigValue("bar")

c = VersionedConfig(MyConfig({"foo": "baz"}), version=1)

c.update(version=2, bar="bazzinga")

c.reset()
assert c.bar is None


def test_valid_values_validator():
# Case sensitive
v = EnumerationValidator(["foo", "Bar", "baz"], case_sensitive=False)
Expand Down