Skip to content

Workflow fails if categories property is missing in the properties file #41

Closed
@SableRaf

Description

@SableRaf

Description:

The workflow currently fails if the categories property is missing from the properties file provided as input. This results in a KeyError when attempting to access props['categories'].

Error log excerpt:

File "/home/runner/work/processing-contributions/processing-contributions/scripts/add_new_contribution_to_yaml.py", line 18, in <module>
    if props['categories']:
       ~~~~~^^^^^^^^^^^^^^
KeyError: 'categories'
Error: Process completed with exit code 1.

Steps to Reproduce:

  1. Run the workflow with a properties file that does not include the categories property (for example: https://github.com/KrabCode/LazyGui/releases/download/latest/LazyGui.txt)
  2. Observe the workflow failing with the above error.

Proposed Solution:

Add a check for the existence of the key and provide a default value (None) if it is not present:

if 'categories' in props and props['categories']:
    props['categories'] = sorted(props['categories'].replace('"', '').split(','))
    props['categories'] = [category.strip() for category in props['categories']]
else:
    props['categories'] = None

Additional Notes

I'll make a PR shortly that will address this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions