Pull requests / #785

#785 serve tests: test_json_schema_text_format's schema failure only where jsonschema is installed

closed · @sergqwer · 0 comments · View on GitHub

Setup & installServer & APIWindows

Description

`serve.test_responses.OverHttp.test_json_schema_text_format` fails on every install without `jsonschema`, including a clean v0.1.39:

```
self.assertEqual((code, r["error"]["code"]), (502, "structured_output_failed"))
TypeError: 'NoneType' object is not subscriptable
```

`jsonschema` is optional (`serve/structured.py`). Without it, a `json_schema` answer is only checked to be one JSON object. The test's "bad" case answers `{"n": 3}` against a schema that wants `n` as a string. That answer is a JSON object, so it passes with a 200 where the test expects the 502.

The test now checks the schema failure only when `jsonschema` imports, which is how `test_structured.py` already treats it (`HAVE_JSONSCHEMA`). Everything before that part of the test still runs either way.

Checked on Windows 11 with the server's venv, which has no `jsonschema`: `serve.test_responses` was 1 error before and is OK now.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VZy1yKaDDiA8a7svdwaHio

Related on strata.com

Editorial links to help you install, pick models, or read release notes — not part of the upstream thread.