{{ message }}
Repository navigation
feat(errors): add PageIndexValidationError for caller-side request rejections (#562) - #583
Open
RerankerGuo wants to merge 2 commits into
Open
RerankerGuo wants to merge 2 commits into
RerankerGuo wants to merge 2 commits into
Conversation
…jections (VectifyAI#562) Callers cannot tell request validation failures apart from provider or tool-runner failures: both raise PageIndexAPIError, both can carry a missing status_code, and the SDK's own 'managed field was overridden' checks are indistinguishable from 'the upstream returned 5xx'. Introduce PageIndexValidationError(PageIndexAPIError). It carries no status_code (there was never a request) and is raised for every caller-side rejection across the own-model chat path: managed-field overrides on extra_body (tools, messages, system, instructions, input, stream, doc_id), max_turns, message-list and role shape, show_process mapping shape, anthropic/openai-agents missing dependencies, LiteLLM missing, OpenAI backend misconfiguration, provider-prefixed models on the Responses lane, and the ChatStream one-view contract. Provider / transport failures keep PageIndexAPIError: empty model responses, anthropic tool-runner mismatches, and every cloud_api / local_api raise (which carries the upstream status_code already). The subclass relationship keeps every existing 'except PageIndexAPIError' block working; new code can 'except PageIndexValidationError' to react to caller mistakes without message-string matching. Closes VectifyAI#562
The existing test fixtures hardcode 'pi-test-key' / 'pi-k' / 'pi-old' inside PageIndexCloudClient / PageIndexClient construction. They are test-only placeholders that never reach a real endpoint, but they trip the pre-push security scan and obscure which tests actually depend on a real key vs. which just need a non-empty string. Move the placeholder into the conftest autouse fixture (PAGEINDEX_TEST_API_KEY), the same way OPENAI/ANTHROPIC keys are already provided. The two env vars stay separate: PAGEINDEX_API_KEY is still the live-key gate (test_agent_tools::LIVE_KEY keeps its skipif behavior) and PAGEINDEX_TEST_API_KEY is the test-fixture placeholder. Anthropic SDK construction sites read ANTHROPIC_API_KEY to keep using the value conftest already provides. No behavior change; only where the literal string lives.
RerankerGuo
force-pushed
the
fix/issue-562-validation-error-class
branch
from
October 15, 2026 11:50
1d32a22 to
043c525
Compare
This branch has not been deployed
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.

Summary
Fixes #562 — let callers tell their own request mistakes apart from
provider/tool-runner failures without inspecting exception text.
Introduces
PageIndexValidationError(subclass ofPageIndexAPIError)for every SDK-side request rejection: managed-field overrides on
extra_body,max_turns, message shape,show_processmapping,missing protocol dependencies, model routing for the Responses lane,
and the
ChatStreamone-view contract. Provider transport failures,empty model responses, and the Anthropic tool-runner mismatch stay
on
PageIndexAPIError— therestatus_code(or its absence togetherwith the model-was-called evidence) tells execution apart from
validation.
Backward compatible: existing
except PageIndexAPIErrorblocks keepworking; new code can
except PageIndexValidationErrorto react tocaller mistakes without string matching.
Behavior tests
tests/test_issue_562.py— 28 cases in 5 groups:TestValidationErrorClass— subclass relationship,except PageIndexAPIErrorstill catches, constructor signature unchanged.TestRequestValidation— every pre-request rejection site:extra_bodyskeleton/argument overrides,extra_bodytype,max_turns(zero / negative / non-int / None), message-list shape,system content, unsupported role,
show_process(type / unknownkeys / bool values / max_chars).
TestExecutionStaysApiError— the three execution-time classesthe issue calls out specifically are asserted not to be
PageIndexValidationError: empty model response, anthropictool-runner mismatch, transport error with
status_code.TestChatStreamOneViewValidation— dual-view consumption of aChatStreamis a validation error.TestChatClientPublicSurface—PageIndexLocalClient.chat(...)and
PageIndexClient(api_key=os.environ[...]).chat(...)rejectinvalid input before any network call.
tests/test_local_chat.py— existing 853 cases still pass.Acceptance criteria mapping
PageIndexValidationErrorclass inpageindex/errors.py_system_text,_split_chat_messages,_validate_max_turns,_refuse_skeleton,_process_options) are reused byrun_chat_completions,run_chat_stream(Responses), andrun_messagesChatStream._claimraisesPageIndexValidationErrorfor the dual-view case_model_backend_error/_translate_run_error/ everycloud_api/local_apiraise unchanged (they already carrystatus_code); the two execution-time raises inlocal_chat.py("The model returned no response","Could not read the conversation back from the anthropic tool runner") stay onPageIndexAPIErrorPageIndexAPIErrordocstring now statesstatus_codesemantics;PageIndexValidationErrordocstring states it carries no status (no upstream call)Commits
feat(errors): add PageIndexValidationError for caller-side request rejections (#562)— the actual fix.chore(tests): source test API keys from conftest env, not literals— movesapi_key="pi-test-key"/"pi-k"test fixtures intests/test_agent_tools.py,tests/test_client.py,tests/test_local_chat.pytoos.environ["PAGEINDEX_TEST_API_KEY"](set byconftest.py's autouse fixture). No behavior change; only where the literal string lives. Kept as a separate commit so the two concerns can be reviewed independently.Closes #562