Skip to content

Feat: add new tests and tescases for restful api suite - #15038

Merged
JinHai-CN merged 6 commits into
infiniflow:mainfrom
6ba3i:test/restful3
May 20, 2026
Merged

JinHai-CN merged 6 commits into
infiniflow:mainfrom
6ba3i:test/restful3

Conversation

@6ba3i

@6ba3i 6ba3i commented May 20, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

extend restful api suite

Type of change

  • New Feature (non-breaking change which adds functionality)
  • Other (please describe): test

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🧪 test Pull requests that update test cases. labels May 20, 2026
@6ba3i 6ba3i added the ci Continue Integration label May 20, 2026
@6ba3i
6ba3i marked this pull request as draft May 20, 2026 06:28
@6ba3i
6ba3i marked this pull request as ready for review May 20, 2026 06:28
@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds comprehensive RESTful API test coverage across three test files: chunk CRUD endpoints, a Dify retrieval route unit test harness, and integration tests for the /retrieval endpoint. Together, these tests validate auth, parameter contracts, concurrency, ownership/authorization, pagination, and data-mutation behavior across multiple REST APIs.

Changes

Chunk Endpoint Contract Testing

Layer / File(s) Summary
Imports and test helpers
test/testcases/restful_api/test_chunks.py
ThreadPoolExecutor, OS constants, and ownership/auth constants imported; _chunk_count() and _reset_chunk_batch() helpers added to manage test preconditions with indexing consistency polling.
Add endpoint: auth, field contracts, ownership, concurrency
test/testcases/restful_api/test_chunks.py
Auth-required tests for chunk add; extensive field contract tests for important_keywords, questions, tag_kwd (type enforcement, empty handling, duplicates); invalid dataset/document ownership tests; repeated-add idempotence and post-deletion behavior; concurrent add with chunk-count verification.
Delete endpoint: basic, detailed, legacy variants, concurrency
test/testcases/restful_api/test_chunks.py
Auth-required delete tests; basic delete contracts (invalid IDs, empty payloads, remaining counts); detailed delete with partial invalid, duplicate IDs, idempotent re-deletes, and ownership errors; web-legacy delete variants; concurrent single-chunk deletes and bulk delete flows with delete-all re-population.
List/Get endpoint: default retrieval, filtering, pagination, concurrency
test/testcases/restful_api/test_chunks.py
Auth-required list tests; default list response and chunk retrieval by ID with not-found error codes; keyword filtering (engine-specific); pagination/page_size with invalid type/value error handling; concurrent listing with consistency checks.
Update endpoint: auth, field contracts, ownership, concurrency
test/testcases/restful_api/test_chunks.py
_create_chunk_for_update() helper; auth-required update tests; content/available field contracts; important_keywords/questions/tag_kwd list-of-strings enforcement; invalid target error message distinction; unknown keys and empty payloads acceptance; repeated concurrent updates with post-deletion failure validation.

Dify Retrieval Route Unit Testing

Layer / File(s) Summary
Module stubs and dynamic loader
test/testcases/restful_api/test_dify_retrieval_routes_unit.py
Stub decorators, awaitable wrappers, mock KB/retriever, LLM/tenant services; _load_dify_retrieval_module() injects stubs into sys.modules before importing api/apps/sdk/dify_retrieval.py; _set_request_json() helper for payload monkeypatching.
Retrieval behavior tests: success, exception mapping
test/testcases/restful_api/test_dify_retrieval_routes_unit.py
Tests successful retrieval with KB documents, KG retrieval, metadata and score mapping; maps missing KB to NOT_FOUND; maps chunk-not-found exceptions to NOT_FOUND; maps generic exceptions to SERVER_ERROR.
Request parsing: GET args and POST JSON
test/testcases/restful_api/test_dify_retrieval_routes_unit.py
Validates GET argument type coercion (boolean, numeric) into retrieval request; validates POST JSON payload parsing for same parameter structure.
Argument validation and error messages
test/testcases/restful_api/test_dify_retrieval_routes_unit.py
Asserts ARGUMENT_ERROR code and message fragments for malformed retrieval_setting, missing required arguments, missing query, and non-object structures.

Retrieval Endpoint Integration Testing

Layer / File(s) Summary
Imports and indexing polling helpers
test/testcases/restful_api/test_retrieval.py
ThreadPoolExecutor, requests, system constants added; polling helpers _retrieval_has_question(), _retrieval_has_chunks(), _retrieval_lacks_chunks() validate /retrieval behavior after mutations.
Auth contract tests
test/testcases/restful_api/test_retrieval.py
Validates missing/invalid auth tokens return HTTP 401 with legacy code/message payload for /retrieval endpoint.
Parameter contract tests: pagination, filtering, numeric constraints
test/testcases/restful_api/test_retrieval.py
Validates page/page_size pagination error handling; highlight boolean coercion and type rejection; keyword handling; vector_similarity_weight conversion and top_k range constraints; rerank_id unknown behavior; unknown parameters ignored.
Concurrency and data-mutation tests
test/testcases/restful_api/test_retrieval.py
Multiple concurrent /retrieval requests verified to succeed; deleted single chunks and batch deletes confirmed absent from subsequent retrieval results using polling and create/delete endpoints.
Related questions endpoint tests
test/testcases/restful_api/test_retrieval.py
Fetches system beta token, validates /searchbots/related_questions success, missing-question error, and invalid-authorization behavior via code/message.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • infiniflow/ragflow#14291: The main PR's comprehensive chunk endpoint contract tests directly validate the RESTful chunk route behaviors introduced by this PR's new api/apps/restful_apis/chunk_api.py handlers (add/delete/list/get/update).
  • infiniflow/ragflow#14169: Both PRs validate the Dify-compatible retrieval endpoint's request parsing and argument-validation behavior around retrieval_setting, top_k, numeric coercion, and ARGUMENT_ERROR handling, with the main PR adding /retrieval contract tests while the retrieved PR modifies the underlying api/apps/sdk/dify_retrieval.py implementation.

Suggested labels

size:L, 🧪 test

Poem

🐰 Chunks dance in threads, retrieval routes align,
Tests weave contracts tight, no edge undefined,
Auth barriers hold, parameters constrained,
Concurrency checked—the system's refrained!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title partially relates to the changeset, referring to expanded RESTful API test coverage, but uses unclear phrasing ('tescases' appears to be a typo for 'testcases') and is somewhat vague about what specific testing enhancements are included. Correct the typo 'tescases' to 'testcases' and consider making the title more specific about the scope of test additions, such as mentioning key areas like chunk operations, retrieval, or concurrency testing.
Description check ❓ Inconclusive The description is minimal and lacks detail. While it indicates the PR adds features and tests, it does not adequately explain what specific problems the tests solve, the scope of changes, or why these additions are necessary. Expand the description to explain what testing gaps or issues these new test cases address, provide an overview of the main test areas covered (chunks, retrieval, dify_retrieval routes), and clarify the business value of these enhancements.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
test/testcases/restful_api/test_dify_retrieval_routes_unit.py (1)

70-251: ⚡ Quick win

Add debug logging around dynamic module loading/stubbing flow.

This helper introduces a complex new flow (module injection + dynamic import) but has no trace logs, which makes CI diagnosis harder when import-time failures happen. Add lightweight debug logs at key steps (module path resolution, stub registration, module execution).

As per coding guidelines, **/*.py: Add logging for new flows.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_dify_retrieval_routes_unit.py` around lines
70 - 251, The helper _load_dify_retrieval_module() performs complex dynamic
module creation and import but has no diagnostics; add lightweight debug logs
using the standard logging module at key steps: after computing repo_root and
module_path, after creating/registering major stubs (deepdoc/deepdoc.parser,
api.db.services.tenant_llm_service, api.db.services.llm_service,
api.db.joint_services.tenant_model_service), after setting module.manager =
_DummyManager, and immediately before/after spec.loader.exec_module(module) to
capture import-time errors; use logging.getLogger(__name__) and logger.debug
calls referencing those symbols (repo_root, module_path, monkeypatch.setitem
registrations, module.manager, spec.loader.exec_module) so CI can show where
failures occur.
test/testcases/restful_api/test_retrieval.py (2)

117-151: ⚡ Quick win

Add diagnostic logging to new polling helpers.

These are new retrying flows; without logs, timeout failures are hard to triage in CI (no status/payload context per attempt).

Proposed diff
+import logging
@@
+logger = logging.getLogger(__name__)
@@
 def _retrieval_has_question(rest_client, dataset_id, question):
     res = rest_client.post("/retrieval", json={"question": question, "dataset_ids": [dataset_id]})
     if res.status_code != 200:
+        logger.debug("retrieval_has_question: status=%s body=%s", res.status_code, res.text)
         return False
     payload = res.json()
     if payload["code"] != 0:
+        logger.debug("retrieval_has_question: code=%s payload=%s", payload.get("code"), payload)
         return False
@@
 def _retrieval_has_chunks(rest_client, dataset_id, question, chunk_ids):
@@
     if res.status_code != 200:
+        logger.debug("retrieval_has_chunks: status=%s body=%s", res.status_code, res.text)
         return False
@@
     if payload["code"] != 0:
+        logger.debug("retrieval_has_chunks: code=%s payload=%s", payload.get("code"), payload)
         return False
@@
 def _retrieval_lacks_chunks(rest_client, dataset_id, question, chunk_ids):
@@
     if res.status_code != 200:
+        logger.debug("retrieval_lacks_chunks: status=%s body=%s", res.status_code, res.text)
         return False
@@
     if payload["code"] != 0:
+        logger.debug("retrieval_lacks_chunks: code=%s payload=%s", payload.get("code"), payload)
         return False

As per coding guidelines, "**/*.py: Add logging for new flows".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_retrieval.py` around lines 117 - 151, The
three retry helpers (_retrieval_has_question, _retrieval_has_chunks,
_retrieval_lacks_chunks) lack per-attempt diagnostic logs; update each to log
the REST call outcome and key variables on every attempt (e.g., log
res.status_code, any JSON payload or parse error, computed retrieved_ids and
expected_ids, and a short message indicating which check is being evaluated) so
CI timeouts include context. Use the project's logger (or Python logging)
consistent with other tests, log at debug/info level for successful attempts and
warn on non-200 or non-zero payload["code"], and include function name and the
question/dataset_id in the message to make failures triageable.

313-318: ⚡ Quick win

Add explicit assertions to polling helper calls for test clarity.

The @wait_for decorator raises AssertionError on timeout, so these calls technically fail the test if expectations aren't met. However, ignoring the True return value obscures intent and makes the test fragile to decorator changes. Add explicit assertions to make test expectations unambiguous.

Suggested changes
-    _retrieval_has_chunks(rest_client, dataset_id, content, [chunk_id])
+    assert _retrieval_has_chunks(rest_client, dataset_id, content, [chunk_id])

-    _retrieval_lacks_chunks(rest_client, dataset_id, content, [chunk_id])
+    assert _retrieval_lacks_chunks(rest_client, dataset_id, content, [chunk_id])

-    _retrieval_has_chunks(rest_client, dataset_id, "BATCH_DELETE_TEST_CHUNK", chunk_ids)
+    assert _retrieval_has_chunks(rest_client, dataset_id, "BATCH_DELETE_TEST_CHUNK", chunk_ids)

-    _retrieval_lacks_chunks(rest_client, dataset_id, "BATCH_DELETE_TEST_CHUNK", chunk_ids)
+    assert _retrieval_lacks_chunks(rest_client, dataset_id, "BATCH_DELETE_TEST_CHUNK", chunk_ids)

Also applies to: 333-338

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_retrieval.py` around lines 313 - 318, The
test calls to the polling helpers _retrieval_has_chunks and
_retrieval_lacks_chunks rely on `@wait_for` raising on timeout but do not assert
their return value; update the test to explicitly assert the helpers succeeded
(e.g., assert _retrieval_has_chunks(...) and assert
_retrieval_lacks_chunks(...)) so the intent is clear and resilient to decorator
changes, and apply the same explicit-assert change for the other occurrence
around lines 333-338 as well.
test/testcases/restful_api/test_chunks.py (3)

33-66: ⚡ Quick win

Add lightweight logging in new reset/polling helpers.

These new orchestration flows are central to many tests; adding debug logs will significantly improve failure triage.

As per coding guidelines **/*.py: Add logging for new flows.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_chunks.py` around lines 33 - 66, The new
helpers _reset_chunk_batch and _chunk_count lack diagnostic logs; import and
configure the module-level logger (e.g., import logging; logger =
logging.getLogger(__name__)) and add lightweight debug/info logs in
_reset_chunk_batch to record actions and responses (cleanup/delete start/result,
baseline upload id, each chunk POST id and index, final expected vs actual
counts) and in _chunk_count to log response status, payload code, and the
computed totals so test failures surface useful context; instrument using
logger.debug/info calls referencing the functions _reset_chunk_batch and
_chunk_count.

180-247: ⚡ Quick win

Exception message equality is too runtime-fragile for contract tests.

Several cases compare full Python exception text; these strings can vary by Python/runtime. Prefer substring checks for error-shape validation.

Proposed patch pattern
-                assert body["message"] == expected_message, (scenario_name, body)
+                assert expected_message in body.get("message", ""), (scenario_name, body)

Also applies to: 584-611, 648-714

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_chunks.py` around lines 180 - 247, The test
test_chunk_add_keyword_question_and_tag_contract compares full Python exception
text (body["message"] == expected_message), which is fragile; change the
failure-path assertions so when expected_message is non-empty you assert that
expected_message is a substring of body["message"] (e.g., expected_message in
body["message"]) instead of exact equality, and keep exact equality only for
empty/zero-message cases; update the checks around body["message"] in
test_chunk_add_keyword_question_and_tag_contract (and the other similar tests
mentioned) to use substring membership for runtime-generated exception texts
like TypeError(...) or other dynamic messages.

131-165: ⚡ Quick win

Avoid exact equality on framework-formatted unauthorized messages.

Asserting the full string representation is brittle across framework/version changes; assert a stable fragment instead.

Proposed patch
-        assert payload["message"] == "<Unauthorized '401: Unauthorized'>", (scenario_name, payload)
+        assert "Unauthorized" in payload.get("message", ""), (scenario_name, payload)

Also applies to: 637-646

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_chunks.py` around lines 131 - 165, The tests
test_chunk_add_requires_auth, test_chunk_delete_requires_auth and
test_chunk_list_requires_auth assert the full framework-formatted unauthorized
string which is brittle; update each assertion that checks payload["message"] to
assert a stable fragment instead (for example: assert "Unauthorized" in
payload["message"] or assert "401" in payload["message"]) so the tests validate
the intent without relying on exact framework formatting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/testcases/restful_api/test_chunks.py`:
- Around line 488-492: After asserting the bulk delete response code, actually
verify the chunks were removed: iterate over the chunk ids in bulk_ids and for
each call the API to fetch that chunk (use rest_client.get with the appropriate
chunk retrieval endpoint used elsewhere in these tests, e.g., GET on base_path +
f"/{chunk_id}" or the existing single-chunk retrieval helper) and assert the
response indicates non-existence (404 or no result); update the test after the
bulk_payload["code"] == 0 assertion to perform these per-chunk retrieval checks
using rest_client.get and asserting failure/absence for each chunk_id from
bulk_ids.
- Line 64: The call to _chunk_count(rest_client, base_path, count + 1) is used
as a precondition but its return value is ignored; change the test to capture
and assert the return (e.g., result = _chunk_count(rest_client, base_path, count
+ 1); assert result) so the test fails clearly when the wait condition times
out—update the invocation in the test to assert the boolean/expected value
returned by _chunk_count using the existing rest_client and base_path
parameters.

---

Nitpick comments:
In `@test/testcases/restful_api/test_chunks.py`:
- Around line 33-66: The new helpers _reset_chunk_batch and _chunk_count lack
diagnostic logs; import and configure the module-level logger (e.g., import
logging; logger = logging.getLogger(__name__)) and add lightweight debug/info
logs in _reset_chunk_batch to record actions and responses (cleanup/delete
start/result, baseline upload id, each chunk POST id and index, final expected
vs actual counts) and in _chunk_count to log response status, payload code, and
the computed totals so test failures surface useful context; instrument using
logger.debug/info calls referencing the functions _reset_chunk_batch and
_chunk_count.
- Around line 180-247: The test test_chunk_add_keyword_question_and_tag_contract
compares full Python exception text (body["message"] == expected_message), which
is fragile; change the failure-path assertions so when expected_message is
non-empty you assert that expected_message is a substring of body["message"]
(e.g., expected_message in body["message"]) instead of exact equality, and keep
exact equality only for empty/zero-message cases; update the checks around
body["message"] in test_chunk_add_keyword_question_and_tag_contract (and the
other similar tests mentioned) to use substring membership for runtime-generated
exception texts like TypeError(...) or other dynamic messages.
- Around line 131-165: The tests test_chunk_add_requires_auth,
test_chunk_delete_requires_auth and test_chunk_list_requires_auth assert the
full framework-formatted unauthorized string which is brittle; update each
assertion that checks payload["message"] to assert a stable fragment instead
(for example: assert "Unauthorized" in payload["message"] or assert "401" in
payload["message"]) so the tests validate the intent without relying on exact
framework formatting.

In `@test/testcases/restful_api/test_dify_retrieval_routes_unit.py`:
- Around line 70-251: The helper _load_dify_retrieval_module() performs complex
dynamic module creation and import but has no diagnostics; add lightweight debug
logs using the standard logging module at key steps: after computing repo_root
and module_path, after creating/registering major stubs (deepdoc/deepdoc.parser,
api.db.services.tenant_llm_service, api.db.services.llm_service,
api.db.joint_services.tenant_model_service), after setting module.manager =
_DummyManager, and immediately before/after spec.loader.exec_module(module) to
capture import-time errors; use logging.getLogger(__name__) and logger.debug
calls referencing those symbols (repo_root, module_path, monkeypatch.setitem
registrations, module.manager, spec.loader.exec_module) so CI can show where
failures occur.

In `@test/testcases/restful_api/test_retrieval.py`:
- Around line 117-151: The three retry helpers (_retrieval_has_question,
_retrieval_has_chunks, _retrieval_lacks_chunks) lack per-attempt diagnostic
logs; update each to log the REST call outcome and key variables on every
attempt (e.g., log res.status_code, any JSON payload or parse error, computed
retrieved_ids and expected_ids, and a short message indicating which check is
being evaluated) so CI timeouts include context. Use the project's logger (or
Python logging) consistent with other tests, log at debug/info level for
successful attempts and warn on non-200 or non-zero payload["code"], and include
function name and the question/dataset_id in the message to make failures
triageable.
- Around line 313-318: The test calls to the polling helpers
_retrieval_has_chunks and _retrieval_lacks_chunks rely on `@wait_for` raising on
timeout but do not assert their return value; update the test to explicitly
assert the helpers succeeded (e.g., assert _retrieval_has_chunks(...) and assert
_retrieval_lacks_chunks(...)) so the intent is clear and resilient to decorator
changes, and apply the same explicit-assert change for the other occurrence
around lines 333-338 as well.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 52f546f9-4470-4170-b8db-8d7ebbcb2f26

📥 Commits

Reviewing files that changed from the base of the PR and between 2836a93 and a1fcf79.

📒 Files selected for processing (3)
  • test/testcases/restful_api/test_chunks.py
  • test/testcases/restful_api/test_dify_retrieval_routes_unit.py
  • test/testcases/restful_api/test_retrieval.py

assert payload["code"] == 0, (index, payload)
chunk_ids.append(_assert_created_chunk_id(payload))

_chunk_count(rest_client, base_path, count + 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Assert the chunk-count wait outcome explicitly.

_chunk_count(...) is called for precondition sync, but its return value is ignored. Making it explicit prevents silent continuation when the wait condition fails.

Proposed patch
-    _chunk_count(rest_client, base_path, count + 1)
+    assert _chunk_count(rest_client, base_path, count + 1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_chunk_count(rest_client, base_path, count + 1)
assert _chunk_count(rest_client, base_path, count + 1)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_chunks.py` at line 64, The call to
_chunk_count(rest_client, base_path, count + 1) is used as a precondition but
its return value is ignored; change the test to capture and assert the return
(e.g., result = _chunk_count(rest_client, base_path, count + 1); assert result)
so the test fails clearly when the wait condition times out—update the
invocation in the test to assert the boolean/expected value returned by
_chunk_count using the existing rest_client and base_path parameters.

Comment on lines +488 to +492
bulk_res = rest_client.delete(base_path, json={"chunk_ids": bulk_ids})
assert bulk_res.status_code == 200
bulk_payload = bulk_res.json()
assert bulk_payload["code"] == 0, bulk_payload

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Bulk-delete path should assert final state, not only response code.

The second bulk-delete scenario stops at code == 0 and doesn’t verify chunks are actually gone.

Proposed patch
     bulk_res = rest_client.delete(base_path, json={"chunk_ids": bulk_ids})
     assert bulk_res.status_code == 200
     bulk_payload = bulk_res.json()
     assert bulk_payload["code"] == 0, bulk_payload
+    after_bulk_payload = rest_client.get(base_path, params={"page_size": 200}).json()
+    assert after_bulk_payload["code"] == 0, after_bulk_payload
+    assert after_bulk_payload["data"]["total"] == 0, after_bulk_payload
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bulk_res = rest_client.delete(base_path, json={"chunk_ids": bulk_ids})
assert bulk_res.status_code == 200
bulk_payload = bulk_res.json()
assert bulk_payload["code"] == 0, bulk_payload
bulk_res = rest_client.delete(base_path, json={"chunk_ids": bulk_ids})
assert bulk_res.status_code == 200
bulk_payload = bulk_res.json()
assert bulk_payload["code"] == 0, bulk_payload
after_bulk_payload = rest_client.get(base_path, params={"page_size": 200}).json()
assert after_bulk_payload["code"] == 0, after_bulk_payload
assert after_bulk_payload["data"]["total"] == 0, after_bulk_payload
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/restful_api/test_chunks.py` around lines 488 - 492, After
asserting the bulk delete response code, actually verify the chunks were
removed: iterate over the chunk ids in bulk_ids and for each call the API to
fetch that chunk (use rest_client.get with the appropriate chunk retrieval
endpoint used elsewhere in these tests, e.g., GET on base_path + f"/{chunk_id}"
or the existing single-chunk retrieval helper) and assert the response indicates
non-existence (404 or no result); update the test after the bulk_payload["code"]
== 0 assertion to perform these per-chunk retrieval checks using rest_client.get
and asserting failure/absence for each chunk_id from bulk_ids.

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (6796a47) to head (a1fcf79).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15038   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files          10       10           
  Lines         713      713           
  Branches      116      116           
=======================================
  Hits          664      664           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 🌈 python Pull requests that update Python code size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants