@@ -568,7 +568,8 @@ async def test_import_index_with_overwrite_fallback_to_create(
568568 validation_call = mock_api .post .call_args_list [0 ]
569569 assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
570570 assert "indexing_yaml" in validation_call .kwargs ["json" ]
571- assert validation_call .kwargs ["json" ]["name" ] == "test_index_fallback"
571+ # When overwrite=True, name should be excluded from validation payload
572+ assert "name" not in validation_call .kwargs ["json" ]
572573
573574 # Check PATCH attempt
574575 patch_call = mock_api .patch .call_args_list [0 ]
@@ -609,7 +610,8 @@ async def test_import_pipeline_with_overwrite_true(
609610 validation_call = mock_api .post .call_args_list [0 ]
610611 assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
611612 assert "query_yaml" in validation_call .kwargs ["json" ]
612- assert validation_call .kwargs ["json" ]["name" ] == "test_pipeline_overwrite"
613+ # When overwrite=True, name should be excluded from validation payload
614+ assert "name" not in validation_call .kwargs ["json" ]
613615
614616 # Check overwrite call
615617 overwrite_call = mock_api .put .call_args_list [0 ]
@@ -655,7 +657,8 @@ async def test_import_pipeline_with_overwrite_fallback_to_create(
655657 validation_call = mock_api .post .call_args_list [0 ]
656658 assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
657659 assert "query_yaml" in validation_call .kwargs ["json" ]
658- assert validation_call .kwargs ["json" ]["name" ] == "test_pipeline_fallback"
660+ # When overwrite=True, name should be excluded from validation payload
661+ assert "name" not in validation_call .kwargs ["json" ]
659662
660663 # Check PUT attempt
661664 put_call = mock_api .put .call_args_list [0 ]
@@ -1339,3 +1342,151 @@ async def test_multiple_validation_errors_logged_individually(
13391342 )
13401343 assert error_log is not None , f"Expected to find log for error code { error_code } "
13411344 assert error_message in error_log .get ("event" , "" ), f"Expected error message '{ error_message } ' in log"
1345+
1346+ @pytest .mark .asyncio
1347+ async def test_validate_index_excludes_name_when_overwrite_true (
1348+ self ,
1349+ pipeline_service : PipelineService ,
1350+ test_pipeline : Pipeline ,
1351+ mock_api : AsyncMock ,
1352+ ) -> None :
1353+ """Test that index validation excludes name from JSON payload when overwrite=True."""
1354+ # Mock successful validation response
1355+ validation_response = Mock (spec = Response )
1356+ validation_response .status_code = HTTPStatus .NO_CONTENT .value
1357+
1358+ # Mock successful import response
1359+ import_response = Mock (spec = Response )
1360+ import_response .status_code = HTTPStatus .OK .value
1361+
1362+ mock_api .post .side_effect = [validation_response , import_response ]
1363+ mock_api .patch .return_value = import_response
1364+
1365+ config = IndexConfig (
1366+ name = "test_index" ,
1367+ inputs = IndexInputs (files = ["file_type_router.sources" ]),
1368+ strict_validation = False ,
1369+ overwrite = True ,
1370+ )
1371+
1372+ await pipeline_service .import_async (test_pipeline , config )
1373+
1374+ # Check validation call
1375+ validation_call = mock_api .post .call_args_list [0 ]
1376+ assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
1377+
1378+ # When overwrite=True, name should be excluded from validation payload
1379+ validation_json = validation_call .kwargs ["json" ]
1380+ assert "name" not in validation_json
1381+ assert "indexing_yaml" in validation_json
1382+
1383+ @pytest .mark .asyncio
1384+ async def test_validate_index_includes_name_when_overwrite_false (
1385+ self ,
1386+ pipeline_service : PipelineService ,
1387+ test_pipeline : Pipeline ,
1388+ mock_api : AsyncMock ,
1389+ ) -> None :
1390+ """Test that index validation includes name in JSON payload when overwrite=False."""
1391+ # Mock successful validation response
1392+ validation_response = Mock (spec = Response )
1393+ validation_response .status_code = HTTPStatus .NO_CONTENT .value
1394+
1395+ # Mock successful import response
1396+ import_response = Mock (spec = Response )
1397+ import_response .status_code = HTTPStatus .OK .value
1398+
1399+ mock_api .post .side_effect = [validation_response , import_response ]
1400+
1401+ config = IndexConfig (
1402+ name = "test_index" ,
1403+ inputs = IndexInputs (files = ["file_type_router.sources" ]),
1404+ strict_validation = False ,
1405+ overwrite = False ,
1406+ )
1407+
1408+ await pipeline_service .import_async (test_pipeline , config )
1409+
1410+ # Check validation call
1411+ validation_call = mock_api .post .call_args_list [0 ]
1412+ assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
1413+
1414+ # When overwrite=False, name should be included in validation payload
1415+ validation_json = validation_call .kwargs ["json" ]
1416+ assert validation_json ["name" ] == "test_index"
1417+ assert "indexing_yaml" in validation_json
1418+
1419+ @pytest .mark .asyncio
1420+ async def test_validate_pipeline_excludes_name_when_overwrite_true (
1421+ self ,
1422+ pipeline_service : PipelineService ,
1423+ test_pipeline : Pipeline ,
1424+ mock_api : AsyncMock ,
1425+ ) -> None :
1426+ """Test that pipeline validation excludes name from JSON payload when overwrite=True."""
1427+ # Mock successful validation response
1428+ validation_response = Mock (spec = Response )
1429+ validation_response .status_code = HTTPStatus .NO_CONTENT .value
1430+
1431+ # Mock successful import response
1432+ import_response = Mock (spec = Response )
1433+ import_response .status_code = HTTPStatus .OK .value
1434+
1435+ mock_api .post .side_effect = [validation_response , import_response ]
1436+ mock_api .put .return_value = import_response
1437+
1438+ config = PipelineConfig (
1439+ name = "test_pipeline" ,
1440+ inputs = PipelineInputs (query = ["prompt_builder.query" ]),
1441+ outputs = PipelineOutputs (answers = "prompt_builder.prompt" ),
1442+ strict_validation = False ,
1443+ overwrite = True ,
1444+ )
1445+
1446+ await pipeline_service .import_async (test_pipeline , config )
1447+
1448+ # Check validation call
1449+ validation_call = mock_api .post .call_args_list [0 ]
1450+ assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
1451+
1452+ # When overwrite=True, name should be excluded from validation payload
1453+ validation_json = validation_call .kwargs ["json" ]
1454+ assert "name" not in validation_json
1455+ assert "query_yaml" in validation_json
1456+
1457+ @pytest .mark .asyncio
1458+ async def test_validate_pipeline_includes_name_when_overwrite_false (
1459+ self ,
1460+ pipeline_service : PipelineService ,
1461+ test_pipeline : Pipeline ,
1462+ mock_api : AsyncMock ,
1463+ ) -> None :
1464+ """Test that pipeline validation includes name in JSON payload when overwrite=False."""
1465+ # Mock successful validation response
1466+ validation_response = Mock (spec = Response )
1467+ validation_response .status_code = HTTPStatus .NO_CONTENT .value
1468+
1469+ # Mock successful import response
1470+ import_response = Mock (spec = Response )
1471+ import_response .status_code = HTTPStatus .OK .value
1472+
1473+ mock_api .post .side_effect = [validation_response , import_response ]
1474+
1475+ config = PipelineConfig (
1476+ name = "test_pipeline" ,
1477+ inputs = PipelineInputs (query = ["prompt_builder.query" ]),
1478+ outputs = PipelineOutputs (answers = "prompt_builder.prompt" ),
1479+ strict_validation = False ,
1480+ overwrite = False ,
1481+ )
1482+
1483+ await pipeline_service .import_async (test_pipeline , config )
1484+
1485+ # Check validation call
1486+ validation_call = mock_api .post .call_args_list [0 ]
1487+ assert validation_call .kwargs ["endpoint" ] == "pipeline_validations"
1488+
1489+ # When overwrite=False, name should be included in validation payload
1490+ validation_json = validation_call .kwargs ["json" ]
1491+ assert validation_json ["name" ] == "test_pipeline"
1492+ assert "query_yaml" in validation_json
0 commit comments