Skip to content

fix: unreachable case statement due to uppercase strings in receipe parser#3

Open
rkost wants to merge 1 commit intoCERN:masterfrom
rkost:fixReceipeBuildStepTypeMatching
Open

fix: unreachable case statement due to uppercase strings in receipe parser#3
rkost wants to merge 1 commit intoCERN:masterfrom
rkost:fixReceipeBuildStepTypeMatching

Conversation

@rkost
Copy link
Copy Markdown

@rkost rkost commented May 6, 2026

We are using lower() in the match line, thus we cannot have uppercase strings in the case statements.

This bug broke the example recipe located at src/pypts/examples/environment_setup_tools/Package_based_setup/Package_based_recipe.yml:

DEBUG : pypts.recipe : File loader returned recipe_data type: <class 'generator'>
DEBUG : pypts.recipe : Recipe main data keys: dict_keys(['name', 'version', 'recipe_version', 'description', 'main_sequence', 'test_package', 'globals'])
DEBUG : pypts.recipe : Processing sequence 1: main
ERROR : pypts.recipe : Failed to create sequence 'main': name 'sshconnectstep' is not defined
ERROR : pypts.recipe : Failed to load recipe from /home/rkost/repos/cern/pts-framework/src/pypts/examples/environment_setup_tools/Package_based_setup/Package_based_recipe.yml: name 'sshconnectstep' is not defined
Traceback (most recent call last):
  File "/home/rkost/repos/cern/pts-framework/src/pypts/recipe.py", line 427, in __load_recipe
    self.sequences[sequence["sequence_name"]] = Sequence(sequence_data=sequence)
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rkost/repos/cern/pts-framework/src/pypts/recipe.py", line 570, in __init__
    self.steps.append(Step.build_step(step_data))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rkost/repos/cern/pts-framework/src/pypts/recipe.py", line 837, in build_step
    new_step: Step = eval(step_type + "(**step_data)")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
NameError: name 'sshconnectstep' is not defined. Did you mean: 'SSHConnectStep'?

We are using lower() in the match line, thus we cannot have uppercase
strings in the case statements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant