Skip to content

Error: Exception raised 'id when missing from compare configuration #5472

Description

@novocane1337

Hi,

I'm getting this "Error: Exception raised 'id" in the Status Dash. From the log file;

2026-10-10 00:00:21.697547: Error: Exception raised 'id'
2026-10-10 00:00:21.699316: Error: Traceback (most recent call last):
File "/config/predbat.py", line 2256, in run_time_loop
self.update_pred(scheduled=True)
File "/config/predbat.py", line 1435, in update_pred
self.comparison.run_all()
File "/config/compare.py", line 675, in run_all
prior = results.get(tariff["id"], {})
~~~~~~^^^^^^
KeyError: 'id'

2026-10-10 00:00:21.712144: Warn: record_status Error: Exception raised 'id'
2026-10-10 00:00:21.712256: Error: timer_tick caught exception: 'id'

Any help would be much appreciated.

predbat (1).log

Activity

  1. springfall2008 commented on Oct 10, 2026

    @springfall2008
    Owner

    Automated first-pass triage — a maintainer will review before any action is taken.

    Classification: bug
    Priority: medium — the trigger is a config line, but a crash repeats every 5 minutes all day until it is fixed.

    The bug: Compare.run_all() indexes every compare_list entry directly with tariff["id"] (compare.py:675), so an entry in apps.yaml that is missing its id line raises KeyError: 'id' — and because that entry produces no clear message about what is wrong, all the user sees is this error. Everything else in the crash follows from two code facts confirmed below.

    What I found (investigated against current main, v9.3.7-4-gd7d8c607; the reporter runs v9.3.6 — confirmed from the attached log):

    • The log shows the first Scenario complete for tariff: Octopus Cosy line at 2026-10-10 00:00:20, then the KeyError: 'id' traceback at 00:00:21 — i.e. the first entry of the list (id current, name "Octopus Cosy") is processed fine and completed its scenario, and the crash happens when the loop reaches the next entry, on the line before Predbat logs anything about it. So the offending entry is the one after "Octopus Cosy" in the reporter's compare_list.
    • The comparison only runs on the daily midnight window (predbat.py:1432 — scheduled and minutes_now < RUN_EVERY) or while the "Predbat Compare Active" switch is on, which explains why there are no errors on 9 Oct (Predbat was restarted at 14:34 that day, after the midnight window) — the same config would have been crashing unseen at previous midnights only if the list already existed; either way the trigger is in the reporter's apps.yaml.
    • The error then repeats every 5 minutes all day (00:00 through the log's end at 13:15, 162 crashes, one per cycle). That is the second half of the bug: run_all() is called at predbat.py:1435 and the switch is cleared by expose_config("compare_active", False) at predbat.py:1436 — code that only runs if run_all() returns normally. A crash inside run_all() skips the clear, so the True the code itself just wrote stays on, and every following cycle re-enters the comparison and crashes again. Once the config is fixed, that loop self-clears within one cycle (compare completes, the switch resets to False).

    Immediate fix: in apps.yaml, give every compare_list entry an id: line (unique, alphanumeric/underscore — the docs ask for this). The entry that follows "Octopus Cosy" is the one missing it. Removing that entry works too. The apps editor's Add-item template starts from name: + id:, so re-saving the list through the editor will also point at any entry that still lacks one.

    What the code side should do (for a maintainer): run_single() already reads the id defensively (tariff.get("id", ""), compare.py:383) — run_all() should skip an id-less entry with a warning to the log rather than crashing the 5-minute cycle; and the compare_active reset at predbat.py:1436 should sit in a finally (the same pattern the code already uses for the active flag) so a comparison crash cannot re-arm itself every cycle. The apps editor already enforces id + name at save time (\_validate_compare_list(), web.py:4081) — that check is simply not reached when apps.yaml is edited by hand.

    Related: #5133 recorded the same class of defect (a compare id that produces an invalid entity id, spamming 404s instead of crashing) and asked for warnings on invalid compare items — open PR #5143 fixes the publishing half of that but not this crash. PR #5465 touches the same midnight comparison window for a different defect (state left on the live plan). Not duplicates: the cause here is specifically an entry with no id.

  2. changed the title [-]Error: Exception raised 'id[/-] [+]Error: Exception raised 'id when missing from compare configuration[/+] on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions