diff --git a/qa/L0_cuda_shared_memory/cuda_shared_memory_test.py b/qa/L0_cuda_shared_memory/cuda_shared_memory_test.py index f629fa6b16..12ade110f0 100755 --- a/qa/L0_cuda_shared_memory/cuda_shared_memory_test.py +++ b/qa/L0_cuda_shared_memory/cuda_shared_memory_test.py @@ -760,7 +760,7 @@ def test_exceeds_cshm_handle_size_limit(self): error_message, ) self.assertIn( - "exceeds the maximum allowed value", + "exceeds the maximum allowed input size", error_message, ) except ValueError: diff --git a/qa/L0_http/http_test.py b/qa/L0_http/http_test.py index 2ce2ea25c3..9ea65fddf6 100755 --- a/qa/L0_http/http_test.py +++ b/qa/L0_http/http_test.py @@ -499,6 +499,38 @@ def test_duplicate_output_names(self): "Server is not healthy after duplicate output request", ) + 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.", + ) + self.assertIn( + "Invalid value for 'ready': expected a boolean", + response.json()["error"], + ) + + 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() diff --git a/qa/L0_http/test.sh b/qa/L0_http/test.sh index bfe7a94b46..e11cbde38b 100755 --- a/qa/L0_http/test.sh +++ b/qa/L0_http/test.sh @@ -672,7 +672,7 @@ fi TEST_RESULT_FILE='test_results.txt' PYTHON_TEST=http_test.py -EXPECTED_NUM_TESTS=15 +EXPECTED_NUM_TESTS=16 set +e python $PYTHON_TEST >$CLIENT_LOG 2>&1 if [ $? -ne 0 ]; then diff --git a/src/http_server.cc b/src/http_server.cc index 765cfde64b..5cce136ede 100644 --- a/src/http_server.cc +++ b/src/http_server.cc @@ -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); + } } }