Skip to content
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

Fix configuration migrations to work for peripheral connectors #1830

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

navarone-feekery
Copy link
Contributor

@navarone-feekery navarone-feekery commented Oct 23, 2023

This PR is to address a bug with RCF validations/migrations.

When a connector is missing a configuration field, it should be added automatically when it is validated. However, this doesn't work for connectors that are not the "main" connector (defined by id in by config file). This bug most often appears for native connectors, but can also occur for self-managed connectors.

The code here was complicated and I think prone to bugs, so the fix also required a refactor. Any connector being sent through the prepare function should now have its configuration validated for both fields and field properties. Connectors are not treated too differently, so they can all follow the same logic path.

This fix:

  • Combines the field and field property validations into one section
  • Removes the pre-emptive doc update for field property validations (there is only one doc update call now)
  • Ensures all connectors follow the same logic path to keep things DRY
  • Updates existing tests to check if validation works for connectors that are not the "main" connector (set in the config file)

@navarone-feekery navarone-feekery requested a review from a team October 23, 2023 16:00
@navarone-feekery navarone-feekery changed the title Fix migrations to work for peripheral connectors Fix configuration migrations to work for peripheral connectors Oct 23, 2023
Copy link
Member

@sphilipse sphilipse left a comment

Choose a reason for hiding this comment

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

Approving because this generally looks good to me and we want to get this into today's BC.

@navarone-feekery navarone-feekery enabled auto-merge (squash) October 24, 2023 09:03
@navarone-feekery navarone-feekery merged commit 03e2728 into main Oct 24, 2023
@navarone-feekery navarone-feekery deleted the navarone/fix-configuration-migrations branch October 24, 2023 09:09
Comment on lines +807 to +808
missing_fields = simple_config.keys() - current_config.keys()
fields_missing_properties = filter_nested_dict_by_keys(
Copy link
Member

Choose a reason for hiding this comment

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

I think we can avoid checking both missing_fields and fields_missing_properties:

Instead of checking

for config_name, config_obj in current_config.items():
    for k, v in config_obj.items():
        simple_default_value = simple_default_config.get(config_name, {}).get(k)

We can check the default config first:

for config_name, config_obj in simple_default_config.items():
    for k, v in config_obj.items():
        current_value = current_config.get(config_name, {}).get(k)

This will make sure it covers both missing fields and missing properties

@github-actions
Copy link

💚 Backport PR(s) successfully created

Status Branch Result
8.10 #1833
8.11 #1834

The backport PRs will be merged automatically after passing CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants