Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions qa/L0_http/http_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,39 @@ def create_nested_json(depth, value):
except ValueError:
self.fail("Response is not valid JSON")

def test_repository_index_deeply_nested_json(self):
"""Test for deeply nested JSON on model repository index."""
depth = 250000
nested = ("[" * depth) + "true" + ("]" * depth)
payload = '{"ready":' + nested + "}"

# Keep request below default --http-max-input-size so parsing path is exercised.
self.assertLess(len(payload), 64 * 1024 * 1024)

response = requests.post(
"http://localhost:8000/v2/repository/index",
data=payload,
headers={"Content-Type": "application/json"},
timeout=60,
)
self.assertEqual(
400,
response.status_code,
"Expected repository index request to fail on invalid 'ready' type.",
)
Comment on lines +441 to +445
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assertion of error message was missing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added error message assertion.

Copy link
Copy Markdown
Contributor

@yinggeh yinggeh Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can safely assume "error" in response.json() if status code != 200.

self.assertIn("error", response.json())
self.assertIn(
"Invalid value for 'ready': expected a boolean",
response.json()["error"],
)

Comment thread
pskiran1 marked this conversation as resolved.
live_response = requests.get("http://localhost:8000/v2/health/live", timeout=10)
self.assertEqual(
200,
live_response.status_code,
"Expected server to remain live after deeply nested JSON request.",
)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion qa/L0_http/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ fi

TEST_RESULT_FILE='test_results.txt'
PYTHON_TEST=http_test.py
EXPECTED_NUM_TESTS=13
EXPECTED_NUM_TESTS=14
set +e
python $PYTHON_TEST >$CLIENT_LOG 2>&1
if [ $? -ne 0 ]; then
Expand Down
8 changes: 7 additions & 1 deletion src/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,13 @@ HTTPAPIServer::HandleRepositoryIndex(
if (buffer_len > 0) {
triton::common::TritonJson::Value ready_json;
if (index_request.Find("ready", &ready_json)) {
err = ready_json.AsBool(&ready);
if (!ready_json.IsBool()) {
err = TRITONSERVER_ErrorNew(
TRITONSERVER_ERROR_INVALID_ARG,
"Invalid value for 'ready': expected a boolean");
} else {
err = ready_json.AsBool(&ready);
}
}
}

Expand Down
Loading