🧩 Improved Error Message for Invalid parameters.key
Summary: Adds clarity for YAML debugging in Observation mode.
URL: https://gitlab.com/esa/pyxel/-/merge_requests/1093
Date: 2025-10-22
📖 Overview
This update improves how Pyxel handles invalid parameters.key values in the Observation mode.
Previously, a vague KeyError made debugging difficult when a user referenced an incorrect key in the YAML configuration.
Project Details
- Project: Pyxel – ESA GitLab
- Branch:
enhance-keyerror-observation - Area:
pyxel/observation/observation.py - Type: Developer Experience / Error Handling
- Merge Request: !1093
🧠 Change Summary
The validate_steps() method in the Observation class has been updated to:
- Detect which part of the parameter key is invalid.
- Visually highlight the incorrect segment with a caret (
^). - Add a clear explanatory message, e.g.
"Non-existing parameter".
💡 Example Before and After
Before:
KeyError: "Missing parameter: 'cfg.pipeline.charge_generation.exponential_qe.arguments.x_epi'" After:
KeyError: "Missing parameter: 'cfg.pipeline.charge_generation.exponential_qe.arguments.x_epi'
^^^^^
Non-existing parameter" This new message clearly identifies the problematic part of the key, improving clarity and debugging speed for all users.
🧪 Testing
A dedicated test script run_observation_test.py was written to simulate invalid keys.
It confirmed that the improved error message displays correctly and clearly.
🦕 Authored by: Doby Baxter
🌌 Contribution for: ESA Pyxel Project