Skip to content

Wrong configuration key leads to exception instead of error message #268

Description

@MakisH

A typo to a key makes the Micro-Manager (v0.9.0) throw an exception. An error message that the key is not recognized would have been nicer.

Wrong config example (micro_file should be micro_file_name):

{
    "micro_file": "python/micro.py"
}

Exception:

(0) 05/19/2026 02:01:01 PM - micro_manager.micro_manager - INFO - Micro Manager version: 0.9.0
(0) 05/19/2026 02:01:01 PM - micro_manager.micro_manager - INFO - Reading JSON configuration file: /foo/micro/test.json
Traceback (most recent call last):
  File "/foo/venv/bin/micro-manager-precice", line 6, in <module>
    sys.exit(main())
             ~~~~^^
  File "/foo/venv/lib/python3.14/site-packages/micro_manager/__init__.py", line 114, in main
    manager = MicroManagerCoupling(config_file_path, log_file=args.log_file)
  File "/foo/venv/lib/python3.14/site-packages/micro_manager/micro_manager.py", line 62, in __init__
    self._config.read_json_micro_manager()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/foo/venv/lib/python3.14/site-packages/micro_manager/config.py", line 239, in read_json_micro_manager
    self._read_json(self._config_file_name)  # Read base information
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/foo/venv/lib/python3.14/site-packages/micro_manager/config.py", line 126, in _read_json
    self._data["micro_file_name"]
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'micro_file_name'

In longer config files, the exception looks more daunting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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