Browse Source

Fix: Improve dataset name validation in KB app (#8188)

### What problem does this PR solve?

- Trim whitespace before checking for empty dataset names
- Change length check from >= to > DATASET_NAME_LIMIT for consistency

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.1
Liu An 4 months ago
parent
commit
e87ad8126c
No account linked to committer's email address
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      api/apps/kb_app.py

+ 2
- 2
api/apps/kb_app.py View File

@@ -45,9 +45,9 @@ def create():
dataset_name = req["name"]
if not isinstance(dataset_name, str):
return get_data_error_result(message="Dataset name must be string.")
if dataset_name == "":
if dataset_name.strip() == "":
return get_data_error_result(message="Dataset name can't be empty.")
if len(dataset_name.encode("utf-8")) >= DATASET_NAME_LIMIT:
if len(dataset_name.encode("utf-8")) > DATASET_NAME_LIMIT:
return get_data_error_result(
message=f"Dataset name length is {len(dataset_name)} which is large than {DATASET_NAME_LIMIT}")


Loading…
Cancel
Save