Repository navigation
fix(hass): log an unparseable apps.yaml to predbat.log with a !secret hint (#5530) - #5642
Conversation
… hint (#5530) A mistyped secret reference such as 'api_key: !openrouter_api_key' or '!secrets name' is an unknown YAML tag. Startup printed the PyYAML error and exited, so it only reached the add-on console and predbat.log showed nothing but the restart loop. Route it through Hass.log() with the tag, its line/column and a "did you mean '!secret ...'" hint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated cleanup summary from the triage bot. Nothing has been pushed; see the end of this comment for why. The branch is already up to date with 1. CI failure on
Two branches that do not contain this PR's change fail identically on 3.15.0, and the "clean" control ran on 3.14.8. Each row was checked against the job log ( Not verified: the exact 3.15 change. It looks as if
A re-run of this PR's CI may pass if it lands on a 3.14 runner. 2. Raw credential echoed as an unknown tag ( 3. Tests:
The test now points Why nothing was pushed: the quick suite inside |
|
Automated cleanup failed to complete for this PR. Reason: The run exited cleanly but left 3 file(s) with uncommitted changes, so its fixes were never pushed. They are stashed in the bot's clone before the next flow runs. Failed at: |
…et; log a missing pred_bat section or file too describe_apps_yaml_error() now repeats an unknown tag only when it names a key in secrets.yaml (or is the literal !secret/!secrets), so a raw credential pasted after a '!' never reaches predbat.log. Hass.__init__ also routes the KeyError (no pred_bat section) and OSError (missing file) that load_apps_yaml() raises through the same logged message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Automated cleanup check from the triage bot. Nothing here needs a maintainer to act.
One known gap is unchanged from the earlier reply: an empty |
|
Automated cleanup failed to complete for this PR. Reason: The run exited cleanly but left 6 file(s) with uncommitted changes, so its fixes were never pushed. They are stashed in the bot's clone before the next flow runs. Failed at: |
|
Automated cleanup check from the triage bot. Nothing here needs a maintainer to act.
One known gap is still unchanged: an empty |
…-tag-log-5530 Resolve the hass.py conflict: keep the PR's logged apps.yaml error, and pass main's per-instance apps_file/secrets_file through to load_apps_yaml, load_secrets and describe_apps_yaml_error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This is an automated draft PR generated from issue #5530 — a maintainer should review it before merging.
Fixes #5530
Summary
A mistyped secret reference in
apps.yaml(api_key: !openrouter_api_key, or!secrets name) is an unknown YAML tag, soyaml.safe_load()raisesConstructorError.Hass.__init__caught it with a bareprint(exc)andsys.exit(1), so the reason went only to the add-on console andpredbat.logshowed nothing but the repeating "Loading secrets / Loading apps.yaml" pairs.The error now goes through
Hass.log()(so it lands inpredbat.log, and as anError:line it is still echoed to the console). A newdescribe_apps_yaml_error()inutils.pymakes it actionable:Error: Unable to load apps.yaml - unknown tag '!openrouter_api_key' at line 671 column 18; only !secret is supported, did you mean '!secret openrouter_api_key'?!secrets/ other!secret…variants: same, withdid you mean '!secret <name>'?Error: Unable to load apps.yaml - it is not valid YAML: <PyYAML message on one line>Startup still exits:
apps.yamlis the boot config, so there is nothing to continue loading with (per the triage comment). The restart-on-exit loop belongs to the add-on wrapper and is unchanged.Testing
test_apps_yaml_error_reaches_predbat_loginapps/predbat/tests/test_secrets.py(registered inrun_secrets_tests) constructsHass()against three badapps.yamlfiles (unknown tag,!secrets, malformed YAML), asserts it exits, and checkspredbat.logholds theError:line, tag, location and hint.tools/triage_test.sh secretsfails without the fix (source stashed; all 11 assertions fail becausepredbat.logholds no error text) and passes with it../run_pre_commitpasses, including the quick suite (All tests passed (4 slow tests skipped)).Notes
impactonHass.__init__: LOW, no upstream callers in the index (only constructed at bootstrap).describe_apps_yaml_erroris new and only called from there.describe_apps_yaml_error()repeatsload_apps_yaml()'sPREDBAT_APPS_FILE/apps.yamldefault to name the file. I left that duplicated rather than changeload_apps_yaml()'s signature, whichfox.pyalso uses.predbat.log, where before it only went to the console. If someone pasted a raw API key as the tag (api_key: !sk-...), that value would reach the log unredacted, because args and secrets haven't loaded at that point. This seemed an unlikely shape compared with the misnamed-reference case the issue shows, so I didn't add a guard.tools/debug-journal.mdalready has the "only Loading apps.yaml pairs in predbat.log" symptom row for this issue. Once this merges, that row should say the error now appears in predbat.log.🤖 Generated with Claude Code