Skip to content

Fix exception in normalize_schemas for conflicting actor config schemas - #925

Merged
pirat89 merged 2 commits into
oamg:mainfrom
matejmatuska:fix-config-typerror
May 21, 2026
Merged

Fix exception in normalize_schemas for conflicting actor config schemas#925
pirat89 merged 2 commits into
oamg:mainfrom
matejmatuska:fix-config-typerror

Conversation

@matejmatuska

@matejmatuska matejmatuska commented May 20, 2026

Copy link
Copy Markdown
Member

The normalize_schemas function incorrectly raises an exception when a config schema (subclass of Config) is contained more than once in it's input, regardless of whether it's a conflicting (same section and name, but a difference in other members) or the same (same section and name).

Traceback example:

Traceback (most recent call last):
  File "/usr/bin/leapp", line 33, in <module>
    sys.exit(load_entry_point('leapp==0.21.0', 'console_scripts', 'leapp')())
  File "/usr/lib/python3.9/site-packages/leapp/cli/__init__.py", line 51, in main
    cli.command.execute('leapp version {}'.format(VERSION))
  File "/usr/lib/python3.9/site-packages/leapp/utils/clicmd.py", line 111, in execute
    args.func(args)
  File "/usr/lib/python3.9/site-packages/leapp/utils/clicmd.py", line 133, in called
    self.target(args)
  File "/usr/lib/python3.9/site-packages/leapp/cli/commands/upgrade/breadcrumbs.py", line 169, in wrapper
    return f(*args, breadcrumbs=breadcrumbs, **kwargs)
  File "/usr/lib/python3.9/site-packages/leapp/cli/commands/preupgrade/__init__.py", line 86, in preupgrade
    command_utils.load_actor_configs_and_store_it_in_db(context, repositories, cfg)
  File "/usr/lib/python3.9/site-packages/leapp/cli/commands/command_utils.py", line 291, in load_actor_configs_and_store_it_in_db
    actor_config_schemas = actor_config.normalize_schemas(actor_config_schemas)
  File "/usr/lib/python3.9/site-packages/leapp/actors/config.py", line 180, in normalize_schemas
    if unique_name in added_fields and added_fields[unique_name] != field:
TypeError: 'set' object is not subscriptable

The added_fields variable is a set. The condition for checking conflicts attempts to do indexing on the set, which is not possible in Python sets and results in a TypeError.

This patch removes the set altogether since it doesn't bring any advantage over just using the normalized_schemas dict.

Comment thread leapp/actors/config.py Outdated
@matejmatuska
matejmatuska force-pushed the fix-config-typerror branch from 1d49624 to dd68ff6 Compare May 20, 2026 11:16
@matejmatuska matejmatuska changed the title Fix config typerror Fix exception in normalize_schemas for conflicting actor config schemas May 20, 2026
@matejmatuska
matejmatuska force-pushed the fix-config-typerror branch from dd68ff6 to 662b8ed Compare May 20, 2026 11:19
Comment thread tests/scripts/test_actor_config.py Outdated
The normalize_schemas function incorrectly raises an exception when a
config schema (subclass of Config) is contained more than once in it's
input, regardless of whether it's a conflicting (same section and name,
but a difference in other members) or the same (same section and name).
Traceback:

Traceback (most recent call last):
  File "/usr/bin/leapp", line 33, in <module>
    sys.exit(load_entry_point('leapp==0.21.0', 'console_scripts', 'leapp')())
  File "/usr/lib/python3.9/site-packages/leapp/cli/__init__.py", line 51, in main
    cli.command.execute('leapp version {}'.format(VERSION))
  File "/usr/lib/python3.9/site-packages/leapp/utils/clicmd.py", line 111, in execute
    args.func(args)
  File "/usr/lib/python3.9/site-packages/leapp/utils/clicmd.py", line 133, in called
    self.target(args)
  File "/usr/lib/python3.9/site-packages/leapp/cli/commands/upgrade/breadcrumbs.py", line 169, in wrapper
    return f(*args, breadcrumbs=breadcrumbs, **kwargs)
  File "/usr/lib/python3.9/site-packages/leapp/cli/commands/preupgrade/__init__.py", line 86, in preupgrade
    command_utils.load_actor_configs_and_store_it_in_db(context, repositories, cfg)
  File "/usr/lib/python3.9/site-packages/leapp/cli/commands/command_utils.py", line 291, in load_actor_configs_and_store_it_in_db
    actor_config_schemas = actor_config.normalize_schemas(actor_config_schemas)
  File "/usr/lib/python3.9/site-packages/leapp/actors/config.py", line 180, in normalize_schemas
    if unique_name in added_fields and added_fields[unique_name] != field:
TypeError: 'set' object is not subscriptable

The added_fields variable is a set. The condition for checking conflicts
attempts to do indexing on the set, which is not possible in Python sets
and results in a TypeError.

This patch removes the set altogether since it doesn't bring any
advantage over just using the normalized_schemas dict.

Also add unit tests for the function.
The test rules always lints, add a variant which just tests.
@matejmatuska
matejmatuska force-pushed the fix-config-typerror branch from ec33aae to 7b66ef6 Compare May 21, 2026 10:11

@pirat89 pirat89 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm now. we discussed the problem and changes via call and all requested changes have been delivered.

@pirat89
pirat89 merged commit 0a5b9b7 into oamg:main May 21, 2026
27 checks passed
@matejmatuska
matejmatuska deleted the fix-config-typerror branch May 25, 2026 09:11
@matejmatuska matejmatuska added the changelog-checked The merger/reviewer checked the changelog draft document and updated it when relevant label Jul 29, 2026
@matejmatuska matejmatuska mentioned this pull request Jul 29, 2026
pirat89 pushed a commit that referenced this pull request Jul 29, 2026
## Packaging
- Bump leapp-framework to 6.6 (#913, #919, #921, #929)

### Fixes
- Change how commands are converted for text based report from the list representation (#919, #921)
- Fix the crashing check of conflicts between actor config schemes (#925)

### Enhancements
- Introduce the format_list function for unified presentation of lists in reports and logs (#913)

## stdlib
### Enhancements
- Introduce the format_list function for unified presentation of lists in reports and logs (#913)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug changelog-checked The merger/reviewer checked the changelog draft document and updated it when relevant

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants