mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-23 08:56:42 +08:00
Fix: go restful api tests (#17247)
This commit is contained in:
@@ -102,7 +102,7 @@ func ValidateName(name string) error {
|
||||
// Validate name is not empty after trimming
|
||||
trimmedName := strings.TrimSpace(name)
|
||||
if trimmedName == "" {
|
||||
return fmt.Errorf("name can't be empty")
|
||||
return fmt.Errorf("name cannot be empty or whitespace")
|
||||
}
|
||||
|
||||
// Validate name length in bytes (not characters) - same as Python len(search_name.encode("utf-8"))
|
||||
|
||||
@@ -105,7 +105,7 @@ func (h *MemoryHandler) CreateMemory(c *gin.Context) {
|
||||
}
|
||||
|
||||
// Validate required field: name
|
||||
if req.Name == "" {
|
||||
if strings.TrimSpace(req.Name) == "" {
|
||||
common.ResponseWithCodeData(c, common.CodeArgumentError, nil, "name is required")
|
||||
return
|
||||
}
|
||||
@@ -892,8 +892,10 @@ func isArgumentError(msg string) bool {
|
||||
// Define list of argument error prefixes
|
||||
// Matches Python ArgumentException error messages
|
||||
argumentErrorPrefixes := []string{
|
||||
"memory name cannot be empty", // Memory name cannot be empty
|
||||
"memory name cannot be empty", // Python: "Memory name cannot be empty or whitespace."
|
||||
"name cannot be empty", // ValidateName trimmed-empty case
|
||||
"memory name exceeds limit", // Memory name exceeds limit
|
||||
"name length is", // ValidateName exceeds limit
|
||||
"memory type must be a list", // memory_type must be a list
|
||||
"memory type is not supported", // Unsupported memory_type
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ GO_ONLY_SKIPS = {
|
||||
"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_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_session_create_validation_and_deleted_chat_contract",
|
||||
"test_session_delete_basic_scenarios",
|
||||
"test_session_list_filter_and_deleted_chat_contract",
|
||||
|
||||
@@ -48,8 +48,8 @@ def create_memory_resource(rest_client, memory_cleanup):
|
||||
payload = {
|
||||
"name": f"{name_prefix}_{uuid.uuid4().hex[:8]}",
|
||||
"memory_type": ["raw"],
|
||||
"embd_id": "BAAI/bge-small-en-v1.5@Builtin",
|
||||
"llm_id": "glm-4-flash@ZHIPU-AI",
|
||||
"embd_id": "BAAI/bge-small-en-v1.5@Local@Builtin",
|
||||
"llm_id": "glm-4-flash@CI@ZHIPU-AI",
|
||||
}
|
||||
res = rest_client.post("/memories", json=payload)
|
||||
assert res.status_code == 200
|
||||
|
||||
@@ -23,8 +23,8 @@ def _memory_payload(name: str) -> dict:
|
||||
return {
|
||||
"name": name,
|
||||
"memory_type": ["raw"],
|
||||
"embd_id": "BAAI/bge-small-en-v1.5@Builtin",
|
||||
"llm_id": "glm-4-flash@ZHIPU-AI",
|
||||
"embd_id": "BAAI/bge-small-en-v1.5@Local@Builtin",
|
||||
"llm_id": "glm-4-flash@CI@ZHIPU-AI",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user