Skip to content

Commit d83ce2d

Browse files
committed
fix(schema): add case management kinds to envelope.schema.json kind enum
validate_authored_envelope() rejected CaseNotificationGroup, CaseSla, and CaseTemplate because the JSON Schema kind enum was never updated when those kinds were added to KIND_TO_TYPE in v0.5.8. The Python provider registry and template discovery were correct; only the schema validator was stale. Adds a drift-guard test (test_schema_kind_enum_matches_kind_to_type) that asserts schema enum == KIND_TO_TYPE.keys() so the two cannot diverge again.
1 parent f990411 commit d83ce2d

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
## [Unreleased]
44

5+
## v0.5.9 — hotfix: accept case management kinds in schema validator
6+
7+
### Fixed
8+
9+
- **`talonctl validate` now accepts `CaseNotificationGroup`, `CaseSla`, and
10+
`CaseTemplate` envelopes.** The JSON Schema enum in
11+
`schemas/envelope.schema.json` was never updated when the three case kinds
12+
were added to `KIND_TO_TYPE`, causing `validate_authored_envelope()` to
13+
reject all case management templates with an "is not one of" error. The
14+
Python code (provider registry, template discovery, `VALID_KINDS`) was
15+
correct; only the JSON Schema enum was stale.
16+
- **Drift-guard test added** (`test_schema_kind_enum_matches_kind_to_type`)
17+
that asserts the schema's kind enum exactly matches `KIND_TO_TYPE.keys()`,
18+
so the two sources of truth cannot diverge again.
19+
520
## v0.5.8 — case management resources (notification groups, SLAs, templates)
621

722
### Added

src/talonctl/schemas/envelope.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"apiVersion": { "const": "talon/v2" },
1010
"kind": {
1111
"type": "string",
12-
"enum": ["Detection", "SavedSearch", "LookupFile", "Workflow", "Dashboard", "RtrScript", "RtrPutFile"]
12+
"enum": ["Detection", "SavedSearch", "LookupFile", "Workflow", "Dashboard", "RtrScript", "RtrPutFile", "CaseNotificationGroup", "CaseSla", "CaseTemplate"]
1313
},
1414
"metadata": {
1515
"type": "object",

tests/unit/test_envelope_validation.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,27 @@ def test_whitespace_hygiene_checks_metadata_and_nested():
8787
env = Envelope("talon/v2", "Dashboard", {"resource_id": "d"}, {"widgets": {"w1": {"queryString": "#a\n| b \n"}}})
8888
errs = check_whitespace_hygiene(env)
8989
assert any("trailing whitespace" in e and "widgets.w1.queryString" in e for e in errs)
90+
91+
92+
def test_validate_authored_envelope_accepts_case_kinds():
93+
"""Schema kind enum must include all three case management kinds."""
94+
for kind in ("CaseNotificationGroup", "CaseSla", "CaseTemplate"):
95+
env = Envelope(
96+
"talon/v2", kind,
97+
{"resource_id": "test_resource", "name": "Test"},
98+
{"name": "Test"},
99+
)
100+
errors = validate_authored_envelope(env)
101+
assert errors == [], f"{kind} rejected by schema: {errors}"
102+
103+
104+
def test_schema_kind_enum_matches_kind_to_type():
105+
"""Schema kind enum must stay in sync with KIND_TO_TYPE (drift guard)."""
106+
import json
107+
from importlib import resources as importlib_resources
108+
from talonctl.core.envelope import KIND_TO_TYPE
109+
110+
text = importlib_resources.files("talonctl.schemas").joinpath("envelope.schema.json").read_text()
111+
schema = json.loads(text)
112+
schema_kinds = set(schema["properties"]["kind"]["enum"])
113+
assert schema_kinds == set(KIND_TO_TYPE.keys())

0 commit comments

Comments
 (0)