Repository navigation
fix: test drift on go specific proxy scheme - #16796
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughTests now resolve Python or Go proxy configuration, handle proxy-specific responses and skips, centralize authentication assertions, and adjust REST and SDK expectations. CI runs Infinity and Elasticsearch tests through scheme-specific matrices. ChangesGo proxy compatibility
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Preflight
participant TestConfig
participant RESTClient
participant Proxy
participant Tests
Preflight->>Preflight: detect changed files and schemes
Preflight-->>TestConfig: provide API_PROXY_SCHEME
TestConfig->>TestConfig: resolve host and proxy settings
RESTClient->>Proxy: send test request
Proxy-->>RESTClient: return JSON or proxy-specific response
RESTClient->>Tests: assert or skip based on response
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (3)
test/testcases/restful_api/test_openai_compatible.py (1)
185-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the duplicated Go-proxy skip condition into a helper.
The same
IS_GO_PROXYupstream-error skip check is copy-pasted in two test functions (lines 185–186 and 238–239). Extracting a small helper would keep them in sync and reduce maintenance burden.♻️ Proposed refactor
+def _skip_if_go_upstream_error(choice_msg, payload): + if IS_GO_PROXY and choice_msg.get("reference") is None and choice_msg.get("content", "").startswith("**ERROR**"): + pytest.skip("Go OpenAI-compatible completion could not reach the configured chat model") + # ... inside each test: choice_msg = payload["choices"][0]["message"] - if IS_GO_PROXY and choice_msg.get("reference") is None and choice_msg.get("content", "").startswith("**ERROR**"): - pytest.skip("Go OpenAI-compatible completion could not reach the configured chat model") + _skip_if_go_upstream_error(choice_msg, payload) assert "reference" in choice_msg, payloadAlso applies to: 238-239
🤖 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_openai_compatible.py` around lines 185 - 186, Extract the duplicated IS_GO_PROXY upstream-error condition into a shared helper in test_openai_compatible.py, using a clear name such as skip_if_go_proxy_upstream_error and accepting the choice message. Replace the inline checks in both affected test functions with calls to this helper, preserving the existing pytest.skip message and behavior.test/testcases/restful_api/conftest.py (1)
191-192: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDead/duplicate check — this condition can never be true.
RestClient.request()inhelpers/client.pyalready inspects every Go-proxy response forcode == 500+"Unknown column 'meta_fields'"and callspytest.skip(...)before returning (helpers/client.py Lines 72-84). Sincepytest.skipraises immediately,rest_client.post(...)at Line 188 would never return that payload here — this duplicate check at Lines 191-192 is unreachable and only adds confusion.♻️ Suggested cleanup
assert res.status_code == 200 payload = res.json() - if IS_GO_PROXY and payload.get("code") == 500 and "Unknown column 'meta_fields'" in payload.get("message", ""): - pytest.skip("Go deployment database schema is missing document.meta_fields") assert payload["code"] == 0, 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/conftest.py` around lines 191 - 192, Remove the unreachable duplicate `IS_GO_PROXY`/`meta_fields` conditional and its `pytest.skip` call following `rest_client.post(...)`; rely on `RestClient.request()` to handle this response before returning.test/testcases/configs.py (1)
42-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd logging for the proxy-mode resolution flow.
API_PROXY_SCHEME/IS_GO_PROXY/HOST_ADDRESSare derived silently from env vars ordocker/.envfallbacks. If the wrong value is picked up (e.g.docker/.envmissing or misread), the whole suite silently targets the wrong host/port with no diagnostic trail. As per coding guidelines, "Add logging for new flows" — consider logging the resolved scheme/host once at import time.♻️ Suggested addition
+import logging + +logger = logging.getLogger(__name__) + def _default_host_address() -> str: if API_PROXY_SCHEME == "go": return f"http://127.0.0.1:{_config_value('GO_HTTP_PORT', '9384')}" return "http://127.0.0.1:9380" HOST_ADDRESS = os.getenv("HOST_ADDRESS") or _default_host_address() +logger.info("Resolved API_PROXY_SCHEME=%s HOST_ADDRESS=%s", API_PROXY_SCHEME, HOST_ADDRESS)🤖 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/configs.py` around lines 42 - 52, Add import-time logging for the resolved proxy configuration near API_PROXY_SCHEME, IS_GO_PROXY, and HOST_ADDRESS, recording the selected scheme, Go-proxy flag, and host address after all environment and fallback resolution is complete.Source: Coding guidelines
🤖 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/conftest.py`:
- Around line 295-302: Add an explicit timeout to both requests.patch calls
configuring the default embedding and rerank LLMs in the setup fixture, using
the same bounded timeout value and existing request conventions. Update the
calls associated with set_default_embedding_response and
set_default_rerank_response so neither can block the test session indefinitely.
In `@test/testcases/restful_api/helpers/client.py`:
- Around line 20-22: Update the imports in the REST API client helper to import
HOST_ADDRESS, IS_GO_PROXY, and VERSION from test.testcases.configs instead of
the top-level configs module, matching the test suite’s package structure and
pytest execution path.
In `@test/testcases/restful_api/test_agents.py`:
- Around line 280-281: Update the response check surrounding the nonstream
payload in the relevant test to safely handle an explicit null data value before
testing for "choices"; use a type-safe fallback or guard so the condition
remains false without raising TypeError, while preserving the existing skip
behavior for wrapped responses.
In `@test/testcases/restful_api/test_datasets.py`:
- Around line 804-809: Move the _skip_go_ignored_null(payload, "name") call
before the assert payload["code"] == ARGUMENT_ERROR_CODE in the name validation
test, matching the ordering used for the other fields so the None case can be
skipped before asserting the error code.
---
Nitpick comments:
In `@test/testcases/configs.py`:
- Around line 42-52: Add import-time logging for the resolved proxy
configuration near API_PROXY_SCHEME, IS_GO_PROXY, and HOST_ADDRESS, recording
the selected scheme, Go-proxy flag, and host address after all environment and
fallback resolution is complete.
In `@test/testcases/restful_api/conftest.py`:
- Around line 191-192: Remove the unreachable duplicate
`IS_GO_PROXY`/`meta_fields` conditional and its `pytest.skip` call following
`rest_client.post(...)`; rely on `RestClient.request()` to handle this response
before returning.
In `@test/testcases/restful_api/test_openai_compatible.py`:
- Around line 185-186: Extract the duplicated IS_GO_PROXY upstream-error
condition into a shared helper in test_openai_compatible.py, using a clear name
such as skip_if_go_proxy_upstream_error and accepting the choice message.
Replace the inline checks in both affected test functions with calls to this
helper, preserving the existing pytest.skip message and 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: 9d49fa3f-2c57-40e4-b666-839638a56a43
📒 Files selected for processing (16)
test/testcases/configs.pytest/testcases/conftest.pytest/testcases/restful_api/conftest.pytest/testcases/restful_api/helpers/assertions.pytest/testcases/restful_api/helpers/client.pytest/testcases/restful_api/test_agents.pytest/testcases/restful_api/test_chats.pytest/testcases/restful_api/test_chunks.pytest/testcases/restful_api/test_datasets.pytest/testcases/restful_api/test_document_raw_routes.pytest/testcases/restful_api/test_documents.pytest/testcases/restful_api/test_memories_messages.pytest/testcases/restful_api/test_openai_compatible.pytest/testcases/restful_api/test_searches.pytest/testcases/restful_api/test_sessions.pytest/testcases/restful_api/test_system.py
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (5)
test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py (1)
247-253: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTernary-inside-
assertis hard to read and duplicated verbatim across two tests.
assert A if COND else B, msgis easy to misparse (it reads like the message is conditional, not the assertion). Bothtest_embedding_model_unsetandtest_embedding_model_nonerepeat the exact same line.♻️ Proposed refactor for clarity
- assert dataset.embedding_model.startswith("BAAI/bge-small-en-v1.5@Local@Builtin") if IS_GO_PROXY else dataset.embedding_model == "BAAI/bge-small-en-v1.5@Local@Builtin", str(dataset) + if IS_GO_PROXY: + assert dataset.embedding_model.startswith("BAAI/bge-small-en-v1.5@Local@Builtin"), str(dataset) + else: + assert dataset.embedding_model == "BAAI/bge-small-en-v1.5@Local@Builtin", str(dataset)Apply the same pattern to both
test_embedding_model_unsetandtest_embedding_model_none.🤖 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/test_sdk_api/test_dataset_mangement/test_create_dataset.py` around lines 247 - 253, Refactor both test_embedding_model_unset and test_embedding_model_none to avoid the ternary expression inside assert and eliminate duplicated validation. Compute the expected embedding model or use an explicit conditional assertion in a clear helper/pattern, while preserving the existing IS_GO_PROXY behavior and str(dataset) failure message.test/testcases/test_sdk_api/common.py (1)
28-31: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding logging to the new skip helper flow.
As per coding guidelines, new flows in
**/*.pyfiles should add logging. The_skip_missing_go_document_metadatahelper introduces a new conditional skip path. A debug-level log when the Go proxy meta_fields error is detected would aid future troubleshooting.🤖 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/test_sdk_api/common.py` around lines 28 - 31, Add a debug-level log inside `_skip_missing_go_document_metadata` when `IS_GO_PROXY` and the missing `meta_fields` condition match, before calling `pytest.skip`, using the existing logging conventions in the module.Source: Coding guidelines
test/testcases/test_sdk_api/conftest.py (1)
81-91: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding logging to the collection modify hook.
As per coding guidelines, new flows in
**/*.pyfiles should add logging. Thepytest_collection_modifyitemshook introduces a new skip-marking flow. A debug-level log summarizing how many items were skipped would help verify correct skip behavior in CI.🤖 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/test_sdk_api/conftest.py` around lines 81 - 91, Add a module-appropriate logger and update pytest_collection_modifyitems to count items marked with the GO_ONLY_PATH_SKIPS rules, then emit a debug-level message summarizing the number skipped and the applicable flow, while preserving the existing early return and marker behavior.Source: Coding guidelines
test/testcases/test_sdk_api/test_message_management/test_add_message.py (1)
20-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
MESSAGE_USER_IDis duplicated between this file andconftest.py.Line 23 defines
MESSAGE_USER_ID = "sdk-api-test-user" if IS_GO_PROXY else "", which is identical toconftest.py:24. If one definition changes, the other can silently drift. Consider importing from a single source (e.g.,configs.pyorconftest.py) instead of redefining.♻️ Proposed fix: centralize MESSAGE_USER_ID
In
configs.py, add:MESSAGE_USER_ID = "sdk-api-test-user" if IS_GO_PROXY else ""Then in both
conftest.pyandtest_add_message.py, replace the local definition with an import:-from configs import IS_GO_PROXY +from configs import MESSAGE_USER_IDAnd remove:
-MESSAGE_USER_ID = "sdk-api-test-user" if IS_GO_PROXY else ""🤖 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/test_sdk_api/test_message_management/test_add_message.py` around lines 20 - 38, Centralize the duplicated MESSAGE_USER_ID definition by adding it to configs.py, then import it in both conftest.py and TestAuthorization in test_add_message.py. Remove the local definitions and retain the existing IS_GO_PROXY-based value in the shared configuration.test/testcases/test_sdk_api/test_memory_management/test_update_memory.py (1)
73-78: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueParametrized
expected_messagevalues are dead whenIS_GO_PROXYis true.When
IS_GO_PROXYis true,expected_messageis unconditionally overwritten at lines 74-77, making the parametrized values at lines 62-64 unused. Consider adding a comment or restructuring to clarify that the parametrized values only apply to the Python proxy path.🤖 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/test_sdk_api/test_memory_management/test_update_memory.py` around lines 73 - 78, Clarify the conditional assertion in the parametrized update-memory test: when IS_GO_PROXY is true, the locally computed expected_message intentionally overrides the parametrized value. Add a concise comment or restructure the logic to explicitly show that parametrized expected_message values apply only to the Python proxy path, while the Go proxy derives its message from name length.
🤖 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/test_sdk_api/test_message_management/test_get_message_content.py`:
- Around line 23-29: Update the `test_auth_invalid` test to pass the
parametrized `invalid_auth` value to `RAGFlow` instead of the hardcoded
`INVALID_API_TOKEN`, ensuring each authorization case, including `None`, is
tested correctly.
In `@test/unit_test/test_testcases/test_config_host_address_unit.py`:
- Around line 65-86: Update test_default_host_address_falls_back_to_docker_env
so its python-scheme cases do not claim to exercise docker-env fallback: remove
the inert docker.env writes, or retarget those assertions to
_docker_env_value/_config_value (or the subprocess-based _host_address) to
verify comment stripping and API_PROXY_SCHEME precedence. Keep
_default_host_address coverage focused on the go branch, which actually reads
GO_HTTP_PORT from docker.env.
---
Nitpick comments:
In `@test/testcases/test_sdk_api/common.py`:
- Around line 28-31: Add a debug-level log inside
`_skip_missing_go_document_metadata` when `IS_GO_PROXY` and the missing
`meta_fields` condition match, before calling `pytest.skip`, using the existing
logging conventions in the module.
In `@test/testcases/test_sdk_api/conftest.py`:
- Around line 81-91: Add a module-appropriate logger and update
pytest_collection_modifyitems to count items marked with the GO_ONLY_PATH_SKIPS
rules, then emit a debug-level message summarizing the number skipped and the
applicable flow, while preserving the existing early return and marker behavior.
In `@test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py`:
- Around line 247-253: Refactor both test_embedding_model_unset and
test_embedding_model_none to avoid the ternary expression inside assert and
eliminate duplicated validation. Compute the expected embedding model or use an
explicit conditional assertion in a clear helper/pattern, while preserving the
existing IS_GO_PROXY behavior and str(dataset) failure message.
In `@test/testcases/test_sdk_api/test_memory_management/test_update_memory.py`:
- Around line 73-78: Clarify the conditional assertion in the parametrized
update-memory test: when IS_GO_PROXY is true, the locally computed
expected_message intentionally overrides the parametrized value. Add a concise
comment or restructure the logic to explicitly show that parametrized
expected_message values apply only to the Python proxy path, while the Go proxy
derives its message from name length.
In `@test/testcases/test_sdk_api/test_message_management/test_add_message.py`:
- Around line 20-38: Centralize the duplicated MESSAGE_USER_ID definition by
adding it to configs.py, then import it in both conftest.py and
TestAuthorization in test_add_message.py. Remove the local definitions and
retain the existing IS_GO_PROXY-based value in the shared configuration.
🪄 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: b8d796b6-ed91-499d-a252-e6ade858ee5c
📒 Files selected for processing (27)
.github/workflows/sep-tests.ymltest/testcases/configs.pytest/testcases/restful_api/test_chats.pytest/testcases/restful_api/test_datasets.pytest/testcases/test_sdk_api/common.pytest/testcases/test_sdk_api/conftest.pytest/testcases/test_sdk_api/test_agent_management/test_agent_crud_unit.pytest/testcases/test_sdk_api/test_chat_assistant_management/test_chat_crud_unit.pytest/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.pytest/testcases/test_sdk_api/test_dataset_mangement/test_delete_datasets.pytest/testcases/test_sdk_api/test_dataset_mangement/test_list_datasets.pytest/testcases/test_sdk_api/test_dataset_mangement/test_update_dataset.pytest/testcases/test_sdk_api/test_memory_management/test_create_memory.pytest/testcases/test_sdk_api/test_memory_management/test_list_memory.pytest/testcases/test_sdk_api/test_memory_management/test_rm_memory.pytest/testcases/test_sdk_api/test_memory_management/test_update_memory.pytest/testcases/test_sdk_api/test_message_management/conftest.pytest/testcases/test_sdk_api/test_message_management/test_add_message.pytest/testcases/test_sdk_api/test_message_management/test_forget_message.pytest/testcases/test_sdk_api/test_message_management/test_get_message_content.pytest/testcases/test_sdk_api/test_message_management/test_get_recent_message.pytest/testcases/test_sdk_api/test_message_management/test_list_message.pytest/testcases/test_sdk_api/test_message_management/test_search_message.pytest/testcases/test_sdk_api/test_message_management/test_update_message_status.pytest/testcases/test_sdk_api/test_session_management/test_create_session_with_chat_assistant.pytest/testcases/test_sdk_api/test_session_management/test_list_sessions_with_chat_assistant.pytest/unit_test/test_testcases/test_config_host_address_unit.py
✅ Files skipped from review due to trivial changes (2)
- test/testcases/test_sdk_api/test_chat_assistant_management/test_chat_crud_unit.py
- test/testcases/test_sdk_api/test_session_management/test_list_sessions_with_chat_assistant.py
🚧 Files skipped from review as they are similar to previous changes (3)
- test/testcases/restful_api/test_chats.py
- test/testcases/configs.py
- test/testcases/restful_api/test_datasets.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16796 +/- ##
==========================================
- Coverage 94.56% 93.16% -1.40%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 668 -10
- Misses 25 29 +4
- Partials 14 20 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
certain tests fail because of test drift and were fixed, other because of go issues