Test: release Go-proxy RESTful contract tests verified passing in Go mode (#17468)

### Summary

Aligns Go and Python error codes/messages so both backends honor the
same RESTful API contract, removing implementation-specific error leaks
(MySQL errors, `ValueError`, `AttributeError`, Gin validator format) in
favor of clean business error codes.

**Chat list** — invalid `orderby` now returns code 101 (was: raw Python
`AttributeError` code 100); invalid `page`/`page_size` values fall back
to defaults (was: raw `ValueError`/`ProgrammingError` code 100).

**Dataset create/update/delete** — adds UUID validation (101),
extra-field rejection (101), duplicate-id detection (101), content-type
/ JSON-syntax / object-shape checks (101), and "lacks permission" for
nonexistent datasets (IDOR). Create auto-deduplicates dataset names.
Pagerank updates tolerate a missing ES index. List response includes
`parser_config` and `pagerank`.

**Session list/update** — adds filtering, sorting, and pagination
support. Empty payloads are valid no-ops. Authorization errors map to
code 109.

**Chunk list** — doc object uses Python key names (`chunk_count`,
`dataset_id`, `chunk_method`, run text status). Add validates list
element types.

**Document update** — adds `chunk_method` alias, pydantic-style Field
error messages, metadata index auto-create with refresh, and "These
documents do not belong to dataset" messages. List validates
`metadata_condition` and reports ownership errors for unmatched name/id
filters.

**Search completion** — `kb_ids` ownership failure returns code 102
instead of 109.

Released 31 contract tests from `GO_ONLY_SKIPS` (all verified passing on
both Go and Python backends with real LLM keys).
This commit is contained in:
euvre
2026-07-30 19:58:49 +08:00
committed by GitHub
parent 75ac8cec2e
commit 8fc20dd9ca
53 changed files with 1138 additions and 426 deletions

View File

@@ -38,77 +38,42 @@ GO_ONLY_SKIPS = {
"test_cancel_missing_task_sets_cancel_contract",
},
"Go validation or response contract does not match the established API contract": {
"test_chat_list_page_and_page_size_contract",
"test_chat_list_sorting_contract",
"test_dataset_update_parser_config_valid_matrix_contract",
"test_dataset_update_parser_config_with_chunk_method_change_contract",
"test_dataset_update_pagerank_contract",
"test_dataset_update_pagerank_set_to_zero_contract",
"test_dataset_update_content_type_and_payload_contract",
"test_dataset_update_identifier_validation_contract",
"test_dataset_update_parser_config_invalid_contract",
"test_dataset_update_field_unset_and_unsupported_contract",
"test_dataset_update_name_invalid_and_duplicate_contract",
"test_dataset_create_name_and_case_insensitive_contract",
# Updating with `{"parser_config": {}}` / `None` is a valid no-op in Go (handled by
# ParserConfigProvided). But the final GET asserts the stored parser_config equals Python's
# DEFAULT_PARSER_CONFIG, which embeds a CI-specific tenant `llm_id` and a richer `graphrag` /
# `parent_child` structure than Go's common.GetParserConfig produces. Exact equality is a
# Python/CI-specific contract, not a meaningful Go behavior difference.
"test_dataset_update_parser_config_defaults_contract",
# Go CreateDataset does not accept parser_config in the request body.
"test_dataset_create_parser_config_different_chunk_methods_contract",
"test_dataset_create_parser_config_missing_raptor_and_graphrag",
"test_dataset_create_embedding_model_contract",
"test_dataset_create_parser_config_bugfix_contract",
"test_dataset_create_content_type_and_payload_bad_contract",
"test_dataset_create_parser_config_invalid_contract",
"test_dataset_create_parser_config_defaults_and_extra_fields_contract",
"test_dataset_list_query_contract_matrix",
"test_dataset_delete_contract_matrix",
# "test_memory_update_invalid_name",
# "test_memory_crud_cycle",
# "test_messages_add_list_recent_content_update_forget",
# "test_message_status_validation_requires_boolean",
# "test_message_search_route_contract",
# "test_memory_crud_and_config",
# "test_messages_list_and_search_validation_contracts",
# "test_message_update_forget_and_content_error_contracts",
"test_dataset_create_embedding_model_contract",
# Empty path (e.g. /chats//sessions) triggers a 405/404 framework
# response in Go rather than the Python contract's code-100 envelope.
"test_session_create_validation_and_deleted_chat_contract",
"test_session_delete_basic_scenarios",
"test_session_list_filter_and_deleted_chat_contract",
"test_session_list_page_and_sort_contract",
"test_session_update_name_and_param_contract",
"test_session_update_requires_auth_and_invalid_target_contract",
"test_chat_completion_validation_errors",
"test_chat_completion_nonstream_with_session",
"test_chat_completion_nonstream_with_chat_without_session",
"test_chat_completion_nonstream_without_chat",
"test_chat_completion_stream_events",
"test_search_completion_sse_shape_when_kb_ids_provided",
"test_system_tokens_auth_and_crud",
# --- exposed after meta_fields skip guard removal ---
# Go response data omits the parser_config key that the contract asserts.
"test_documents_update_parser_config_contract",
},
"Go ingestion pipeline does not complete document parsing within the test timeout": {
# Chunk add requires an embedding model call; document update/delete
# touches ES/Infinity indices that are only created during parsing.
# Without a working Go ingestion pipeline, these indices never exist.
"test_chunk_add_keyword_question_and_tag_contract",
"test_chunk_add_repeated_and_deleted_document_contract",
"test_chunk_concurrent_add_contract",
"test_documents_list_default_concurrent_and_filters_contract",
"test_documents_list_error_and_sorting_contract",
"test_documents_update_patch_and_delete",
"test_documents_update_name_contract",
"test_documents_update_chunk_method_contract",
"test_documents_update_meta_fields_contract",
"test_documents_update_invalid_field_and_guard_contract",
"test_documents_update_parser_config_contract",
"test_documents_metadata_batch_update_contract",
"test_documents_metadata_update_path",
"test_documents_delete_contract_matrix",
"test_documents_delete_invalid_dataset_partial_duplicate_repeat_and_cross_dataset",
"test_documents_delete_concurrent_and_bulk_contract",
"test_documents_download_requires_auth_and_invalid_id_contract",
},
"Go LLM setup cannot exercise the configured model": {
"test_related_questions_contract",
},
"Go ingestion pipeline does not complete document parsing within the test timeout": {
"test_chat_list_concurrent_and_dataset_delete_contract",
"test_chat_create_dataset_ids_contract",
"test_chat_create_llm_contract",
@@ -127,11 +92,9 @@ GO_ONLY_SKIPS = {
"test_retrieval_document_ids_and_metadata_condition_contract",
"test_retrieval_rerank_unknown_contract",
"test_retrieval_concurrent_contract",
"test_documents_parse_and_stop",
"test_documents_parse_contract_matrix",
"test_documents_parse_invalid_dataset_partial_duplicate_and_repeated",
"test_documents_parse_chunks_and_scaled_bulk_contract",
"test_documents_stop_parse_requires_auth",
"test_documents_stop_parse_contract_matrix",
"test_documents_stop_parse_invalid_dataset_partial_and_scaled_concurrency",
"test_documents_table_parser_chat_patterns",