Skip to content

Commit a3cf454

Browse files
committed
fix(policy): Policy.extra=ignore so old persisted files load cleanly (#966)
Persisted tool_policy.json files from an earlier revision of this PR carry default_action (since dropped) and rejected with ValidationError on load — surfacing as 'Could not load policy: 500' when the user clicked the per-tool gated toggle. Predicate/Rule keep extra=forbid (typo catching at construction).
1 parent 8a062ba commit a3cf454

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/ha_mcp/policy/model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ class Policy(BaseModel):
8282
The system is always "allow unless a rule matches; rule = require
8383
approval". There is no global deny/require-approval default — rules
8484
grant approval gates, nothing else.
85+
86+
``extra="ignore"`` so policies persisted by an older version of this
87+
PR (which may carry removed fields like ``default_action``) load
88+
cleanly; the dropped fields are silently discarded on next save.
89+
Predicate/Rule keep ``extra="forbid"`` since those are constructed
90+
from UI / user-typed JSON where typos should fail loudly.
8591
"""
8692

87-
model_config = ConfigDict(extra="forbid")
93+
model_config = ConfigDict(extra="ignore")
8894

8995
enabled: bool = False
9096
wait_seconds: int = Field(default=60, ge=5, le=600)

0 commit comments

Comments
 (0)