Skip to content

Conversation

@MoralCode
Copy link
Contributor

@MoralCode MoralCode commented Jan 6, 2026

Description
This PR corrects a bug that was introduced with the config hierarchy PR in #3378

The bug was that I was using python's builtin update() function to attempt to merge the configs from different sources together (represented as nested dicts). However, update() only updates one level of the dictionary, meaning that the sections were being correctly merged, but the values within each section were just being replaced with the values present in the highest priority config item in the stack, rather than being merged.

This means that values were not correctly "propagating up" thorugh holes in the config. For example, if a value was not present in the database, attempts to retrieve config based on all sources would only return what was in the database, failing to populate any values present in other sources (such as the hardcoded defaults) when they were missing from the database.

In place of update() this PR uses a recursive function found on StackOverflow. Since these config objects are small, this recursive solution should be an acceptable tradeoff. If the config objects start getting really big and/or really nested (hundreds of items) then maybe it should be re-considered, but this scenario doesnt seem especially likely.

This PR fixes #3476

Notes for Reviewers

This was tested with a unit test. to run it without causing a ton of errors from all the tests that still have failing database fixtures, run uv run pytest tests/test_classes/. The unit test is written to purposely not use the database or any database mocks or fixtures so it can be run in more situations (hopefully making the tests easier to run even if they break again in future)

Signed commits

  • Yes, I signed my commits.

…eter and skip the db stuff

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
…or the merging functionality

Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
Signed-off-by: Adrian Edwards <adredwar@redhat.com>
@MoralCode MoralCode requested a review from sgoggins as a code owner January 6, 2026 18:59
from sqlalchemy import and_, update
import json
import copy
from typing import List, Any, Optional
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused List imported from typing (unused-import)

@MoralCode
Copy link
Contributor Author

I also tested this by running Augur before and after this change. Before I observed that the augur_collection_monitor task was failing every 30 seconds (as seen in Flower) with the same exception about the missing config key.

Afterwards, i see these tasks succeeding again

@MoralCode MoralCode added the ready Items tested and seeking additional approvals or a merge. Usually for items under active development label Jan 6, 2026
Signed-off-by: Adrian Edwards <17362949+MoralCode@users.noreply.github.com>
Copy link
Collaborator

@shlokgilda shlokgilda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@sgoggins sgoggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MoralCode MoralCode merged commit 99aacb8 into main Jan 7, 2026
15 checks passed
@MoralCode MoralCode deleted the bugs/config-hierarchy branch January 7, 2026 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Items tested and seeking additional approvals or a merge. Usually for items under active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

commit message variable missing after update

3 participants