Skip to content

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

Merged
asiroliu merged 5 commits into
infiniflow:mainfrom
6ba3i:restful
May 25, 2026
Merged

asiroliu merged 5 commits into
infiniflow:mainfrom
6ba3i:restful

Conversation

@6ba3i

@6ba3i 6ba3i commented May 25, 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 the size:XS This PR changes 0-9 lines, ignoring generated files. label May 25, 2026
@6ba3i 6ba3i added the ci Continue Integration label May 25, 2026
@coderabbitai

coderabbitai Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds concurrency imports and ~20 dataset-creation contract tests covering naming semantics, avatar/description pass-through, chunk_method/permission/embedding_model validation, parser_config matrix/defaults/invalid inputs, scale (1k creations), and concurrent creation.

Changes

Dataset API Contract Testing

Layer / File(s) Summary
Imports and test helpers
test/testcases/restful_api/test_datasets.py
Adds ThreadPoolExecutor, as_completed, DEFAULT_PARSER_CONFIG, and avatar/image helpers for tests.
Basic dataset creation and value contracts
test/testcases/restful_api/test_datasets.py
Case-insensitive names, canonicalized duplicate naming, avatar/description pass-through and null/unset semantics, allowed chunk_method/permission values, embedding-model selection/format checks, and parser_config default population when raptor/graphrag omitted.
Scale and concurrent creation tests
test/testcases/restful_api/test_datasets.py
Sequential creation of 1,000 datasets and ThreadPoolExecutor-based concurrent creation stress test asserting success (code == 0).
Parser config matrix and bugfix checks
test/testcases/restful_api/test_datasets.py
Parameterized valid-matrix assertions for parser_config (including nested dicts) and a bugfix test verifying raptor/graphrag use_* behavior when sub-objects are partially/fully omitted.
Parser config chunk_method defaults
test/testcases/restful_api/test_datasets.py
Vary top-level chunk_method while asserting raptor/graphrag default use_* == False and preserved chunk_token_num.
Name validation and duplicate handling
test/testcases/restful_api/test_datasets.py
Negative tests for invalid names and verification that duplicate creation returns a canonicalized/incremented second name.
Payload and Content-Type error handling
test/testcases/restful_api/test_datasets.py
Unsupported Content-Type, malformed JSON, and non-object JSON payload tests with standardized code == 101 and expected message fragments.
Avatar and description contract tests
test/testcases/restful_api/test_datasets.py
Length and format limits for avatar/description, data-URI/MIME prefix validation, round-trip checks, and unset vs explicit null semantics.
Permission and chunk_method validation
test/testcases/restful_api/test_datasets.py
Invalid permission and chunk_method inputs with expected messages, rejection of explicit None, and defaulting behavior when omitted.
Parser config invalid-input validation
test/testcases/restful_api/test_datasets.py
Extensive negative tests for parser_config fields, nested raptor/graphrag constraints, numeric bounds, and type checks with expected error fragments.
Parser config defaults and extra-field rejection
test/testcases/restful_api/test_datasets.py
Asserts DEFAULT_PARSER_CONFIG is returned for empty/unset/None inputs, equality across those cases, and that extra top-level fields are rejected with “Extra inputs are not permitted”.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A thousand datasets sprout in parallel cheer,
Tests nibble names, avatars, and parsers near.
Matrices check configs while threads race to the line,
One stray test name slips, then quietly resigns.
🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 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.
Description check ❓ Inconclusive The description is incomplete and lacks detail. While it follows the template structure with 'What problem does this PR solve?' and 'Type of change' sections, the problem statement is vague ('extend restful api suite') and lacks the background context required for meaningful review. Expand the problem statement to describe what specific endpoint functionality is being tested and why these tests are necessary. Provide context about contract coverage improvements being made.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title mentions adding new tests and test cases for restful api suite, which directly aligns with the main change of adding 16+ new test functions to expand REST dataset create endpoint coverage.
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: 1

🤖 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_datasets.py`:
- Around line 211-225: The test expectations in
test_dataset_create_parser_config_missing_raptor_and_graphrag (and the similar
block at lines ~382-404) are wrong given the defaulting behavior in
get_parser_config and create_with_name which return the "naive" parser config
that sets use_raptor and use_graphrag to True; update the assertions in
test/testcases/restful_api/test_datasets.py to assert that parser_config
contains "raptor" and "graphrag" and that parser_config["raptor"]["use_raptor"]
is True and parser_config["graphrag"]["use_graphrag"] is True (while keeping the
chunk_token_num assertion) so the test matches
api/utils/api_utils.py:get_parser_config and
api/db/services/knowledgebase_service.py:create_with_name behavior.
🪄 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: e6e356fa-6a73-4269-82ae-40653abb37a4

📥 Commits

Reviewing files that changed from the base of the PR and between 5069561 and 9bb1023.

📒 Files selected for processing (1)
  • test/testcases/restful_api/test_datasets.py

@codecov

codecov Bot commented May 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (5069561) to head (1a7a2ee).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15208   +/-   ##
=======================================
  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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/testcases/restful_api/test_datasets.py (1)

171-188: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix duplicate pytest test name and contract assertion issues in test_datasets.py

  • Duplicate test definition: test_dataset_create_embedding_model_contract is defined at lines 180-187 and redefined at lines 551-578; pytest will only run the latter, dropping the parameterized embedding-model contract coverage (171-188).
  • Missing pytest priority marker: test_dataset_create_name_invalid_and_duplicate_contract (431-455) has no @pytest.mark.p1/p2/p3.
  • Expected error string typo: graphrag_entity_types_not_str_in_list expects "nput should be a valid string" (673); should match the backend message (likely "Input ...").
  • Parser-config defaults assertions: test_dataset_create_parser_config_missing_raptor_and_graphrag (around 213-227) asserts use_raptor and use_graphrag default to False; update if backend defaults differ.
🤖 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_datasets.py` around lines 171 - 188, Rename
or deduplicate the duplicated test function
test_dataset_create_embedding_model_contract so the parameterized version (the
one at the earlier block with `@pytest.mark.parametrize`) is the one executed
(remove or rename the later redefinition), ensure the parameterized test posts
to /datasets and asserts embedding_model contract as before; add an appropriate
pytest priority marker (e.g., `@pytest.mark.p1` or p2) to
test_dataset_create_name_invalid_and_duplicate_contract so it has a priority;
fix the typo in the expected error string for
graphrag_entity_types_not_str_in_list to match the backend message (correct
"nput should be a valid string" to the actual "Input should be a valid string"
or the exact backend text); and update assertions in
test_dataset_create_parser_config_missing_raptor_and_graphrag (the test checking
use_raptor/use_graphrag defaults) to reflect the backend defaults (flip to True
if backend now defaults to True or adjust assertions to assert presence/absence
accordingly).
♻️ Duplicate comments (1)
test/testcases/restful_api/test_datasets.py (1)

213-227: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Parser-config default flag expectations still look inverted.

These assertions expect missing raptor/graphrag defaults to False; if the service still defaults to the naive parser config, these should be True and tests will fail.

Proposed expectation update (if defaults are still naive)
-    assert parser_config["raptor"]["use_raptor"] is False, body
-    assert parser_config["graphrag"]["use_graphrag"] is False, body
+    assert parser_config["raptor"]["use_raptor"] is True, body
+    assert parser_config["graphrag"]["use_graphrag"] is True, body
-        ("test_parser_config_only_raptor", {"chunk_token_num": 1024, "raptor": {"use_raptor": True}}, True, False),
-        ("test_parser_config_only_graphrag", {"chunk_token_num": 1024, "graphrag": {"use_graphrag": True}}, False, True),
+        ("test_parser_config_only_raptor", {"chunk_token_num": 1024, "raptor": {"use_raptor": True}}, True, True),
+        ("test_parser_config_only_graphrag", {"chunk_token_num": 1024, "graphrag": {"use_graphrag": True}}, True, True),
-    assert parser_config["raptor"]["use_raptor"] is False, body
-    assert parser_config["graphrag"]["use_graphrag"] is False, body
+    assert parser_config["raptor"]["use_raptor"] is True, body
+    assert parser_config["graphrag"]["use_graphrag"] is True, body
#!/bin/bash
set -euo pipefail

# Verify defaults in parser config / creation path
files=$(fd -i 'api_utils.py|knowledgebase_service.py' || true)
if [ -z "${files}" ]; then
  echo "Could not locate api_utils.py or knowledgebase_service.py via fd."
  exit 1
fi

echo "Inspecting files:"
echo "${files}"

# Show relevant definitions and default flags
rg -n -C4 'def get_parser_config|def create_with_name|use_raptor|use_graphrag|naive|DEFAULT_PARSER_CONFIG' ${files}

# Show current assertions in this test file
rg -n -C2 'use_raptor|use_graphrag|test_dataset_create_parser_config_' test/testcases/restful_api/test_datasets.py

Also applies to: 384-386, 429-430

🤖 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_datasets.py` around lines 213 - 227, The test
test_dataset_create_parser_config_missing_raptor_and_graphrag currently asserts
that missing parser flags default to False but the service (or
DEFAULT_PARSER_CONFIG) uses the naive parser default True; update the assertions
to expect True for parser_config["raptor"]["use_raptor"] and
parser_config["graphrag"]["use_graphrag"] (and any other similar assertions in
this file — e.g., the other test_dataset_create_parser_config_* cases) or
alternatively change the code paths that build the default parser config
(functions like get_parser_config or create_with_name / DEFAULT_PARSER_CONFIG in
api_utils.py / knowledgebase_service.py) to return False for those flags so the
tests remain correct; pick one approach and make the assertions or defaults
consistent across parser_config handling and the tests.
🤖 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_datasets.py`:
- Line 673: The expected-message string in the invalid-case matrix tuple
("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1,
2]}}, "nput should be a valid string") has a leading character missing; update
that third element to the correct message "Input should be a valid string" so
the test assertion compares against the correct expected error text (locate the
tuple in test_datasets.py near the invalid-case matrix).
- Around line 431-456: The test function
test_dataset_create_name_invalid_and_duplicate_contract is missing a pytest
priority marker; add an appropriate marker (e.g., `@pytest.mark.p1`) directly
above the function definition and ensure pytest is imported in the file (add
"import pytest" at the top if absent) so the test uses the required p1/p2/p3
priority convention.

---

Outside diff comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 171-188: Rename or deduplicate the duplicated test function
test_dataset_create_embedding_model_contract so the parameterized version (the
one at the earlier block with `@pytest.mark.parametrize`) is the one executed
(remove or rename the later redefinition), ensure the parameterized test posts
to /datasets and asserts embedding_model contract as before; add an appropriate
pytest priority marker (e.g., `@pytest.mark.p1` or p2) to
test_dataset_create_name_invalid_and_duplicate_contract so it has a priority;
fix the typo in the expected error string for
graphrag_entity_types_not_str_in_list to match the backend message (correct
"nput should be a valid string" to the actual "Input should be a valid string"
or the exact backend text); and update assertions in
test_dataset_create_parser_config_missing_raptor_and_graphrag (the test checking
use_raptor/use_graphrag defaults) to reflect the backend defaults (flip to True
if backend now defaults to True or adjust assertions to assert presence/absence
accordingly).

---

Duplicate comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 213-227: The test
test_dataset_create_parser_config_missing_raptor_and_graphrag currently asserts
that missing parser flags default to False but the service (or
DEFAULT_PARSER_CONFIG) uses the naive parser default True; update the assertions
to expect True for parser_config["raptor"]["use_raptor"] and
parser_config["graphrag"]["use_graphrag"] (and any other similar assertions in
this file — e.g., the other test_dataset_create_parser_config_* cases) or
alternatively change the code paths that build the default parser config
(functions like get_parser_config or create_with_name / DEFAULT_PARSER_CONFIG in
api_utils.py / knowledgebase_service.py) to return False for those flags so the
tests remain correct; pick one approach and make the assertions or defaults
consistent across parser_config handling and the tests.
🪄 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: b9747ffc-1401-41ad-977d-af35854df9ce

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb1023 and 604e19b.

📒 Files selected for processing (1)
  • test/testcases/restful_api/test_datasets.py

("pages_not_int_list", {"pages": [["string1", "string2"]]}, "Input should be a valid integer"),
("graphrag_type_invalid", {"graphrag": {"use_graphrag": "string"}}, "Input should be a valid boolean"),
("graphrag_entity_types_not_list", {"graphrag": {"entity_types": "1,2"}}, "Input should be a valid list"),
("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1, 2]}}, "nput should be a valid string"),

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

Fix expected-message typo in invalid-case matrix.

Line [673] uses "nput should be a valid string" (missing leading I), which can cause a false assertion failure.

Proposed fix
-        ("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1, 2]}}, "nput should be a valid string"),
+        ("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1, 2]}}, "Input should be a valid string"),
📝 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
("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1, 2]}}, "nput should be a valid string"),
("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1, 2]}}, "Input should be a valid string"),
🤖 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_datasets.py` at line 673, The
expected-message string in the invalid-case matrix tuple
("graphrag_entity_types_not_str_in_list", {"graphrag": {"entity_types": [1,
2]}}, "nput should be a valid string") has a leading character missing; update
that third element to the correct message "Input should be a valid string" so
the test assertion compares against the correct expected error text (locate the
tuple in test_datasets.py near the invalid-case matrix).

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/testcases/restful_api/test_datasets.py (1)

552-552: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Resolve duplicate test function name to fix Ruff F811 and test shadowing.

test_dataset_create_embedding_model_contract is redefined at Line 552, which shadows the earlier definition at Line 180. This breaks linting and silently skips one contract test.

Proposed fix
-@pytest.mark.p2
-def test_dataset_create_embedding_model_contract(rest_client, clear_datasets):
+@pytest.mark.p2
+def test_dataset_create_embedding_model_default_and_invalid_contract(rest_client, clear_datasets):

As per coding guidelines, "Use ruff check and ruff format commands to lint and format Python code".

🤖 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_datasets.py` at line 552, Duplicate test
function name test_dataset_create_embedding_model_contract is shadowing an
earlier test and causing Ruff F811; rename one of the duplicate functions to a
unique, descriptive name (e.g.,
test_dataset_create_embedding_model_contract_with_<scenario> or
test_dataset_create_embedding_model_contract_duplicate) and update any
references or fixtures that call it (keep the test logic identical if it's
intended to be a different scenario). After renaming, run ruff check and ruff
format to ensure linting and formatting pass and adjust any import/test
selection patterns if they relied on the old name.
🤖 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.

Outside diff comments:
In `@test/testcases/restful_api/test_datasets.py`:
- Line 552: Duplicate test function name
test_dataset_create_embedding_model_contract is shadowing an earlier test and
causing Ruff F811; rename one of the duplicate functions to a unique,
descriptive name (e.g.,
test_dataset_create_embedding_model_contract_with_<scenario> or
test_dataset_create_embedding_model_contract_duplicate) and update any
references or fixtures that call it (keep the test logic identical if it's
intended to be a different scenario). After renaming, run ruff check and ruff
format to ensure linting and formatting pass and adjust any import/test
selection patterns if they relied on the old name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9fe92c66-ebb1-4cef-a55d-aa73b1456207

📥 Commits

Reviewing files that changed from the base of the PR and between 604e19b and 82f6933.

📒 Files selected for processing (1)
  • test/testcases/restful_api/test_datasets.py

@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: 1

🤖 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_datasets.py`:
- Around line 211-217: The xfail gate is too broad: restrict the pytest.xfail
call so it only triggers when the error is the specific unauthorized-tenant case
(e.g., payload["code"] == 102 AND payload["message"] contains an
authorization-specific substring like "no authorized tenant" or similar),
instead of xfactoring every 102; update the condition that calls pytest.xfail to
check both unauthorized_is_xfail and an authorization-specific indicator in
payload["message"]; also make the message assertion less brittle by checking
containment (e.g., expected_message in payload["message"]) when expected_message
is provided rather than exact equality; keep existing checks for expected_code
and expected_embedding_model unchanged and reference the variables payload,
unauthorized_is_xfail, pytest.xfail, expected_message, expected_embedding_model,
and embedding_model when editing.
🪄 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: 90a533ee-ef2e-40aa-a294-28523ee55922

📥 Commits

Reviewing files that changed from the base of the PR and between 82f6933 and 1a7a2ee.

📒 Files selected for processing (1)
  • test/testcases/restful_api/test_datasets.py

Comment on lines +211 to +217
if unauthorized_is_xfail and payload["code"] == 102:
pytest.xfail(f"Environment has no authorized tenant model for {embedding_model}: {payload}")
assert payload["code"] == expected_code, payload
if expected_embedding_model is not None:
assert payload["data"]["embedding_model"] == expected_embedding_model, payload
if expected_message is not None:
assert payload["message"] == expected_message, 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

Narrow the xfail gate so real regressions don’t get masked.

The current branch xfails any code == 102 for the tenant case, even when the 102 is unrelated to authorization. Also, exact message equality is brittle for API error text contracts.

Suggested adjustment
-    if unauthorized_is_xfail and payload["code"] == 102:
-        pytest.xfail(f"Environment has no authorized tenant model for {embedding_model}: {payload}")
+    if unauthorized_is_xfail and payload["code"] == 102:
+        message = payload.get("message", "")
+        if "Unauthorized model:" in message:
+            pytest.xfail(f"Environment has no authorized tenant model for {embedding_model}: {payload}")
     assert payload["code"] == expected_code, payload
@@
-    if expected_message is not None:
-        assert payload["message"] == expected_message, payload
+    if expected_message is not None:
+        assert expected_message in payload.get("message", ""), 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
if unauthorized_is_xfail and payload["code"] == 102:
pytest.xfail(f"Environment has no authorized tenant model for {embedding_model}: {payload}")
assert payload["code"] == expected_code, payload
if expected_embedding_model is not None:
assert payload["data"]["embedding_model"] == expected_embedding_model, payload
if expected_message is not None:
assert payload["message"] == expected_message, payload
if unauthorized_is_xfail and payload["code"] == 102:
message = payload.get("message", "")
if "Unauthorized model:" in message:
pytest.xfail(f"Environment has no authorized tenant model for {embedding_model}: {payload}")
assert payload["code"] == expected_code, payload
if expected_embedding_model is not None:
assert payload["data"]["embedding_model"] == expected_embedding_model, payload
if expected_message is not None:
assert expected_message in payload.get("message", ""), 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_datasets.py` around lines 211 - 217, The
xfail gate is too broad: restrict the pytest.xfail call so it only triggers when
the error is the specific unauthorized-tenant case (e.g., payload["code"] == 102
AND payload["message"] contains an authorization-specific substring like "no
authorized tenant" or similar), instead of xfactoring every 102; update the
condition that calls pytest.xfail to check both unauthorized_is_xfail and an
authorization-specific indicator in payload["message"]; also make the message
assertion less brittle by checking containment (e.g., expected_message in
payload["message"]) when expected_message is provided rather than exact
equality; keep existing checks for expected_code and expected_embedding_model
unchanged and reference the variables payload, unauthorized_is_xfail,
pytest.xfail, expected_message, expected_embedding_model, and embedding_model
when editing.

@asiroliu
asiroliu merged commit 7d200d5 into infiniflow:main May 25, 2026
1 of 3 checks passed
@6ba3i
6ba3i deleted the restful branch May 25, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants