Fix: HTTP API Updates Read-Only Dataset Fields During Modification #5923 (#5937)

### What problem does this PR solve?

Fixes #5923 

Fixes the readonly variables from payload at
 /datasets/<dataset_id> 

_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._

Now if user tries to modify readonly values then it will show " The
input parameters are invalid. "

invalid_keys = {"id", "embd_id", "chunk_num", "doc_num", "parser_id",
"create_date", "create_time", "created_by",
"status","token_num","update_date","update_time"}
    if any(key in req for key in invalid_keys):
return get_error_data_result(message="The input parameters are
invalid.")
i have include those readonly keys in invalid_keys

### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: Raghav <2020csb1115@iitrpr.ac.in>
This commit is contained in:
Raghav Patidar
2025-03-12 07:57:02 +05:30
committed by GitHub
parent 1c663b32b9
commit 49d560583f
4 changed files with 6 additions and 6 deletions

View File

@ -68,7 +68,7 @@ def upload_file(auth, dataset_id, path):
def list_document(auth, dataset_id):
authorization = {"Authorization": auth}
url = f"{HOST_ADDRESS}/v1/document/list?kb_id={dataset_id}"
url = f"{HOST_ADDRESS}/v1/document/list?kb_id={dataset_id}"
res = requests.get(url=url, headers=authorization)
return res.json()
@ -85,7 +85,7 @@ def parse_docs(auth, doc_ids):
authorization = {"Authorization": auth}
json_req = {
"doc_ids": doc_ids,
"run": 1
"run": 1
}
url = f"{HOST_ADDRESS}/v1/document/run"
res = requests.post(url=url, headers=authorization, json=json_req)

View File

@ -39,7 +39,7 @@ def list_dataset(auth, params=None):
def update_dataset(auth, dataset_id, payload):
res = requests.put(
url=f"{API_URL}/{dataset_id}", headers=HEADERS, auth=auth, json=payload
url=f"{API_URL}/{dataset_id}", headers=HEADERS, auth=auth, json=payload
)
return res.json()