Skip to content

loadConfig raises confusing TypeError on an empty config file #139

Description

@marcosfrenkel

Summary

Starting the server with an empty (or comments-only) config file fails with an opaque TypeError instead of a message telling the user the file is empty.

Repro

touch serverConfig.yml
instrumentserver -c serverConfig.yml

Actual

File "src/instrumentserver/config.py", line 50, in loadConfig
    if "instruments" not in rawConfig:
TypeError: argument of type 'NoneType' is not iterable

ruamel.yaml's yaml.load() returns None for an empty file, and loadConfig then evaluates "instruments" not in None.

Expected

A clear error, in the spirit of the existing missing-instruments-key message just below it, e.g. "The config file '…' is empty. It needs at least an 'instruments:' section."

Suggested fix

Guard for rawConfig is None right after the yaml.load() call in config.py and raise a descriptive error. (Related to #109, making general exceptions specific.)

Found while writing the Getting Started / quickstart docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions