Fix asset status page crash on old sensors_to_show format#2103
Merged
Conversation
…show format Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/09f0ee2e-71f7-4389-a447-23f20fee1364 Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Documentation build overview
Show files changed (5 files in total): 📝 4 modified | ➕ 0 added | ➖ 1 deleted
|
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/09f0ee2e-71f7-4389-a447-23f20fee1364 Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix asset status page crash on old sensors_to_show format
Fix asset status page crash on old Apr 13, 2026
sensors_to_show format
Flix6x
requested changes
Apr 13, 2026
Contributor
Flix6x
left a comment
There was a problem hiding this comment.
Seems like a reasonable fix, but the pipeline is failing.
…how after test Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/5ce56f2a-9e55-408b-9659-f12da4d6800a Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
Contributor
Author
Fixed in commit |
…ors_to_show after test" This reverts commit 6980c7a. Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…how after test Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/5ce56f2a-9e55-408b-9659-f12da4d6800a Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…ors_to_show after test" This reverts commit 2b53bf4. Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The asset status page crashed with
KeyError: 'sensors'for assets whosesensors_to_showcontained the old singular-key format (e.g.{"title": "Prices", "sensor": 709}).Root cause
get_asset_sensors_metadata()accessedsensor["sensors"]directly on items returned byvalidate_sensors_to_show(). That method normalises all input formats into a"plots"-based structure:{"title": "Prices", "plots": [{"sensor": 709}]}so the top-level
"sensors"key never exists, causing the crash on anysensors_to_showentry.Changes
flexmeasures/data/services/sensors.py— replace the broken direct key access withSensorsToShowSchema.flatten(), which already handles everysensors_to_showvariant (singular"sensor", plural"sensors", and"plots"-wrapped structures). AddSensorsToShowSchemaimport at module level.flexmeasures/api/common/schemas/tests/test_sensor_data_schema.py— add regression testtest_asset_sensors_metadata_old_sensors_to_show_formatcovering the exact mixed format from the bug report: