Skip to content

Fix : Web API tests by normalizing errors, validation, and uploads#12620

Merged
KevinHuSh merged 7 commits intoinfiniflow:mainfrom
6ba3i:web_app_api
Jan 16, 2026
Merged

Fix : Web API tests by normalizing errors, validation, and uploads#12620
KevinHuSh merged 7 commits intoinfiniflow:mainfrom
6ba3i:web_app_api

Conversation

@6ba3i
Copy link
Contributor

@6ba3i 6ba3i commented Jan 14, 2026

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

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jan 14, 2026
@KevinHuSh KevinHuSh requested a review from asiroliu January 15, 2026 01:51
@KevinHuSh KevinHuSh added the ci Continue Integration label Jan 15, 2026
@KevinHuSh KevinHuSh marked this pull request as draft January 15, 2026 02:31
@KevinHuSh KevinHuSh marked this pull request as ready for review January 15, 2026 02:31
@6ba3i 6ba3i added ci Continue Integration and removed ci Continue Integration labels Jan 15, 2026
@6ba3i 6ba3i marked this pull request as draft January 15, 2026 08:59
@6ba3i 6ba3i marked this pull request as ready for review January 15, 2026 08:59
@6ba3i 6ba3i marked this pull request as draft January 15, 2026 09:02
@6ba3i 6ba3i marked this pull request as ready for review January 15, 2026 09:35
@dosubot dosubot bot added the 🐖api The modified files are located under directory 'api/apps/sdk' label Jan 15, 2026
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
Copy link
Collaborator

@KevinHuSh KevinHuSh Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 values returned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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"]},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why deleting 2 times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@KevinHuSh KevinHuSh merged commit 2b20d0b into infiniflow:main Jan 16, 2026
1 of 2 checks passed
@6ba3i 6ba3i deleted the web_app_api branch January 16, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐖api The modified files are located under directory 'api/apps/sdk' 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants