Skip to content

Commit 705b809

Browse files
committed
Add DRAWING_PAGE_COUNT_TOO_LARGE exception type
The core-reader API rejects redaction requests when the incoming drawing exceeds the server page limit, returning a new error type DRAWING_PAGE_COUNT_TOO_LARGE. Teach the client to parse it so the read loop does not crash on an unknown enum value. - Add the member to the v2 TechreadExceptionType enum - Add the member to the legacy v1 W24TechreadExceptionType enum for parity - Bump the package version to 2.6.0 so the server (which gates on the client-reported version > 2.5.0) will emit the new error - Extend the enum tests with the new value and a TechreadMessage round-trip parse test Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M562dp6QvASsxKrmHcQv8A
1 parent 6436261 commit 705b809

4 files changed

Lines changed: 54 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["wheel", "setuptools"]
33

44
[project]
55
name = "werk24"
6-
version = "2.5.0"
6+
version = "2.6.0"
77
description = "AI-powered platform for extracting and analyzing data from technical drawings / CAD drawings to enhance manufacturing workflows."
88
readme = { file = "README.md", content-type = "text/markdown" }
99
license = { file = "LICENSE.txt" }

tests/test_exception_types.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
from uuid import uuid4
2+
13
from werk24.models.v1.techread import W24TechreadExceptionType
2-
from werk24.models.v2.internal import TechreadExceptionType
4+
from werk24.models.v2.internal import (
5+
TechreadExceptionType,
6+
TechreadMessage,
7+
TechreadMessageType,
8+
)
39

410

511
def test_configuration_incorrect_enum_present():
@@ -10,3 +16,39 @@ def test_configuration_incorrect_enum_present():
1016
W24TechreadExceptionType.CONFIGURATION_INCORRECT.value
1117
== "CONFIGURATION_INCORRECT"
1218
)
19+
20+
21+
def test_drawing_page_count_too_large_enum_present():
22+
assert (
23+
TechreadExceptionType.DRAWING_PAGE_COUNT_TOO_LARGE.value
24+
== "DRAWING_PAGE_COUNT_TOO_LARGE"
25+
)
26+
assert (
27+
W24TechreadExceptionType.DRAWING_PAGE_COUNT_TOO_LARGE.value
28+
== "DRAWING_PAGE_COUNT_TOO_LARGE"
29+
)
30+
31+
32+
def test_message_parses_drawing_page_count_too_large():
33+
"""A TechreadMessage carrying the new exception_type must parse
34+
without raising a pydantic ValidationError.
35+
"""
36+
message = TechreadMessage.model_validate_json(
37+
f"""{{
38+
"request_id": "{uuid4()}",
39+
"message_type": "ERROR",
40+
"message_subtype": "COMPLETED",
41+
"exceptions": [
42+
{{
43+
"exception_level": "ERROR",
44+
"exception_type": "DRAWING_PAGE_COUNT_TOO_LARGE"
45+
}}
46+
]
47+
}}"""
48+
)
49+
assert message.message_type == TechreadMessageType.ERROR
50+
assert len(message.exceptions) == 1
51+
assert (
52+
message.exceptions[0].exception_type
53+
== TechreadExceptionType.DRAWING_PAGE_COUNT_TOO_LARGE
54+
)

werk24/models/v1/techread.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ class W24TechreadExceptionType(str, Enum):
121121
""" The paper size is larger that the allowed paper size
122122
"""
123123

124+
DRAWING_PAGE_COUNT_TOO_LARGE = "DRAWING_PAGE_COUNT_TOO_LARGE"
125+
""" The document has more pages than can be processed for an output
126+
that must cover the whole document (e.g. redaction).
127+
"""
128+
124129
DRAWING_MEASURE_SYSTEM_INCOMPLETE = "DRAWING_MEASURE_SYSTEM_INCOMPLETE"
125130
""" The file you submitted contains too few measures to be
126131
manufacturable

werk24/models/v2/internal.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class TechreadExceptionType(str, Enum):
133133
""" The paper size is larger that the allowed paper size
134134
"""
135135

136+
DRAWING_PAGE_COUNT_TOO_LARGE = "DRAWING_PAGE_COUNT_TOO_LARGE"
137+
""" The document has more pages than can be processed for an output
138+
that must cover the whole document (e.g. redaction).
139+
"""
140+
136141

137142
class TechreadException(BaseModel):
138143
"""

0 commit comments

Comments
 (0)