Skip to content

Commit 3db2feb

Browse files
committed
fix(mcp): bound constraints copied into diagnostic details
Bound large schema constraint values (pattern, enum, const) in schema_violation_details to prevent multi-megabyte diagnostic responses. Strings are truncated to 1024 chars; non-string values are JSON-rendered and truncated if the rendered form exceeds 1024.
1 parent 75ec2ef commit 3db2feb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/jacobian/capability_validation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ def schema_violation_details(error: JsonSchemaValidationError) -> dict[str, obje
138138
"const",
139139
"type",
140140
}:
141-
details["constraint"] = error.validator_value
141+
constraint_value = error.validator_value
142+
if isinstance(constraint_value, str):
143+
if len(constraint_value) > 1024:
144+
constraint_value = constraint_value[:1021] + "..."
145+
else:
146+
rendered = json.dumps(constraint_value, ensure_ascii=False)
147+
if len(rendered) > 1024:
148+
constraint_value = rendered[:1021] + "..."
149+
details["constraint"] = constraint_value
142150
return details
143151

144152

0 commit comments

Comments
 (0)