Fix : Web API tests by normalizing errors, validation, and uploads#12620
Merged
KevinHuSh merged 7 commits intoinfiniflow:mainfrom Jan 16, 2026
Merged
Fix : Web API tests by normalizing errors, validation, and uploads#12620KevinHuSh merged 7 commits intoinfiniflow:mainfrom
KevinHuSh merged 7 commits intoinfiniflow:mainfrom
Conversation
… and closing upload handles.
KevinHuSh
reviewed
Jan 15, 2026
KevinHuSh
reviewed
Jan 15, 2026
…e/message in SDK list_memory results
KevinHuSh
reviewed
Jan 15, 2026
api/utils/api_utils.py
Outdated
| msg = repr(e).lower() | ||
| if getattr(e, "code", None) == 401 or ("unauthorized" in msg) or ("401" in msg): | ||
| return get_json_result(code=RetCode.UNAUTHORIZED, message=repr(e)) | ||
| return get_json_result(code=RetCode.UNAUTHORIZED, message="Unauthorized"), RetCode.UNAUTHORIZED |
Contributor
Author
There was a problem hiding this comment.
The first value returns the json body and the second one returns the status code.
A similar result could be achieved by replacing the line with
resp = get_json_result(code=RetCode.UNAUTHORIZED, message="Unauthorized")
resp.status_code = RetCode.UNAUTHORIZED
return resp
We would be manually setting the HTTP status on the response object. Same result but just more verbose.
KevinHuSh
reviewed
Jan 15, 2026
| if has_ids and deleted_count == 0: | ||
| return get_data_error_result(message="Index updating failure") | ||
| if deleted_count > 0 and deleted_count < len(unique_chunk_ids): | ||
| deleted_count += settings.docStoreConn.delete({"doc_id": req["doc_id"]}, |
Contributor
Author
There was a problem hiding this comment.
First delete uses doc_id + chunk_ids to remove only the requested chunks. If only some are deleted, we delete by doc_id alone to wipe all chunks for that doc and restore consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Fixes web API behavior mismatches that caused test failures by normalizing error responses, tightening validations, correcting error messages, and closing upload file handles.
Type of change