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

Bug: Non-existent runners folder in extracted zip causes failure in migrate.py #588

Closed
gpsinghsandhu opened this issue Oct 15, 2022 · 0 comments · Fixed by #589
Closed

Comments

@gpsinghsandhu
Copy link
Contributor

This issue happened when extracting our customised script server zip where the zip didn't include the empty runners directory. This led to the following error:

Traceback (most recent call last):
File "path/to/script-server/./launcher.py", line 11, in
main.main()
File "path/to/script-server/script-server/src/main.py", line 79, in main
migrations.migrate.migrate(TEMP_FOLDER, CONFIG_FOLDER, SERVER_CONF_PATH, LOG_FOLDER)
File path/to/script-server/script-server/src/migrations/migrate.py", line 387, in migrate
migration_descriptor.callable(context)
File "path/to/script-server/script-server/src/migrations/migrate.py", line 269, in __migrate_bash_formatting_to_output_format
for (conf_file, json_object, content) in _load_runner_files(context.conf_folder):
TypeError: 'NoneType' object is not iterable

This is happening since the following function in migrate.py is returning None in case of non-existent runners directory:

def _load_runner_files(conf_folder):
    runners_folder = os.path.join(conf_folder, 'runners')

    if not os.path.exists(runners_folder):
        return

    conf_files = [os.path.join(runners_folder, file)
                  for file in os.listdir(runners_folder)
                  if file.lower().endswith('.json')]

    result = []

    for conf_file in conf_files:
        content = file_utils.read_file(conf_file)
        try:
            json_object = custom_json.loads(content, object_pairs_hook=OrderedDict)
            result.append((conf_file, json_object, content))
        except Exception:
            LOGGER.exception('Failed to load file for migration: ' + conf_file)
            continue

    return result

Submitting a PR for this soon.

gpsinghsandhu added a commit to gpsinghsandhu/script-server that referenced this issue Oct 15, 2022
gpsinghsandhu added a commit to gpsinghsandhu/script-server that referenced this issue Oct 15, 2022
@bugy bugy added the bug label Oct 15, 2022
@bugy bugy closed this as completed in #589 Oct 15, 2022
bugy added a commit that referenced this issue Oct 15, 2022
…er#588

#588 load_runner_files now returns [] in case of non-exisitent runners folder
@bugy bugy added this to the 1.18.0 milestone Oct 15, 2022
@bugy bugy added the resolved label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants