Skip to content

Commit 4d1f8ba

Browse files
authored
Merge pull request #28 from willwebster5/hotfix/case-management-kinds-schema
fix(schema): hotfix v0.5.9 — add case management kinds to envelope schema validator
2 parents f990411 + 8c2a728 commit 4d1f8ba

3 files changed

Lines changed: 41 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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,28 @@ 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",
97+
kind,
98+
{"resource_id": "test_resource", "name": "Test"},
99+
{"name": "Test"},
100+
)
101+
errors = validate_authored_envelope(env)
102+
assert errors == [], f"{kind} rejected by schema: {errors}"
103+
104+
105+
def test_schema_kind_enum_matches_kind_to_type():
106+
"""Schema kind enum must stay in sync with KIND_TO_TYPE (drift guard)."""
107+
import json
108+
from importlib import resources as importlib_resources
109+
from talonctl.core.envelope import KIND_TO_TYPE
110+
111+
text = importlib_resources.files("talonctl.schemas").joinpath("envelope.schema.json").read_text()
112+
schema = json.loads(text)
113+
schema_kinds = set(schema["properties"]["kind"]["enum"])
114+
assert schema_kinds == set(KIND_TO_TYPE.keys())

0 commit comments

Comments
 (0)