Conversation
d61c9a4 to
611879d
Compare
ReviewRebased cleanly onto main. Code reviewed for correctness, security, performance, and codebase consistency. Bug found & fixed: nginx
|
MohanLaksh
left a comment
There was a problem hiding this comment.
PR #3344 Test Failures Analysis
Failing Tests Summary
1. test_ping_invalid_method - Expected 500, Got 400
Location: tests/e2e/test_main_apis.py::TestProtocolAPIs::test_ping_invalid_method
Issue: The PR changed the behavior to return 400 (Bad Request) with JSON-RPC error code -32600 for invalid methods, but the test expects 500.
Test Code (line 453):
assert response.status_code == 500 # Expects 500Actual Behavior: Now returns 400 with proper JSON-RPC error mapping per the PR changes.
2. test_get_version - Expected 200, Got 403
Location: tests/e2e/test_main_apis.py::TestVersionAndDocs::test_get_version
Issue: The PR added admin-only access requirement to /version endpoint via _has_version_admin_access(), but the test expects public access (200).
Root Cause: The test comment says "no auth required" but the PR intentionally restricted this endpoint to admins only for security (preventing information disclosure).
3. test_execute_forwarded_request_returns_error_when_no_server
Location: tests/e2e/test_session_pool_e2e.py::TestMultiWorkerSessionAffinityE2E
Issue: Test expects 'error' key in response but gets {'result': {}} instead.
Root Cause: The PR's error handling changes may have affected how forwarded requests handle missing server scenarios.
4. test_affinity_logs_when_executing_forwarded_request
Location: tests/e2e/test_session_pool_e2e.py::TestMultiWorkerSessionAffinityE2E
Issue: Same as #3 - expects 'error' key but gets {'result': {}}.
Root Cause: Related to session affinity forwarding error handling changes.
Root Cause
All failures are expected behavior changes from the PR:
- Better error codes: 400 instead of 500 for invalid requests (JSON-RPC compliance)
- Security hardening:
/versionnow requires admin access - Error handling improvements: May have changed how certain edge cases are handled in session affinity
Action Required
The tests need to be updated to match the new behavior, not the code fixed. The PR's changes are intentional security and protocol compliance improvements.
Also,
🔍 Areas for Consideration (Non-Blocking)
-
Redundant req_id Extraction (Line 6042 vs 6012)
Impact: Harmless but noisy. Consider removing or consolidating. Not a blocker. -
Error Context for Debugging (Optional Enhancement)
Current behavior returns identical -32600 errors for all invalid request scenarios. Consider adding debug-only context:
Rationale: Helps operators diagnose client misconfigurations without leaking internals in production. Non-blocking if omitted.
- Session Close Idempotency (Document or Handle)
_close_streamable_http_session() returns 500 on remove_session() failure. Clarify:
Should already-closed sessions return 200 (idempotent) or 404 (session not found)?
Log the exception type for debugging transient vs permanent failures: logger.exception("remove_session failed", exc_info=True)
Recommendation: Add docstring noting idempotency behavior and structured exception logging.
- Test Parametrization Coverage (Optional Expansion)
Current tests use @pytest.mark.parametrize effectively. Consider extending to edge cases:
Invalid jsonrpc versions: "1.0", "3.0", null, 123
Method edge cases: empty string "", numeric 12, null
Params edge cases: non-dict when required (array, string, null)
Not required for merge, but improves robustness.
- Nginx Configuration Documentation (Optional)
The removal of security headers from nginx is correct and aligns with the architecture (app middleware is source of truth). Consider noting this decision in README.md to prevent future regressions.
🎯 Final Recommendation
APPROVE — Merge AFTER fixing the failing tests and optionally address:
- (Nice-to-have) Remove redundant req_id extraction (line 6042)
- (Nice-to-have) Document session close idempotency behavior in docstring
- (Future) Expand test parametrization for edge cases
- (Future) Add nginx security header decision to README.md
No security or performance issues detected.
Improve RPC/protocol validation behavior and error mapping, enforce admin-only diagnostics access, and harden stateful streamable HTTP session teardown semantics. Align nginx upstream behavior for replica-aware balancing and remove overlapping proxy security headers. Update and expand unit coverage across main/version/oauth/streamable transport paths. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Update endpoint/helper docstrings for explicit args/returns/raises coverage and keep doctest examples aligned with current admin diagnostics access semantics. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Cover RPC-path SamplingError and CompletionError mapping to JSON-RPC -32602, stateful session owner assertion (404/403 deny paths), ping endpoint non-dict body handling, and streamable HTTP session close error branches (registry None, remove_session failure). Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
- version.py: _has_version_admin_access now accepts string inputs from require_admin_auth (which returns email after verifying admin status) - test_version.py: reference require_admin_auth instead of nonexistent require_auth - test_main_apis.py: ping invalid-method test expects 400 (not 500) - test_main_extended.py: fix params list->dict, remove stale RPCRequest patch Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> Signed-off-by: Jonathan Springer <jps@s390x.com>
9fdf2e8 to
b5ae2a1
Compare
… validation, remove data leaks - Extract _jsonrpc_invalid_request() helper to deduplicate 5 identical error envelope constructions across ping() and _handle_rpc_authenticated() - Skip RPCRequest Pydantic validation for trusted internal Rust dispatch (restores intentional perf optimization; manual type checks still run) - Remove session_id from JSONRPCError data to avoid reflecting client input - Remove full params dict from SamplingError/CompletionError JSON-RPC errors to prevent request payload leakage in error responses Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> Signed-off-by: Jonathan Springer <jps@s390x.com>
Summary
Notes
tests/unit/scripts/test_demo_a2a_agent_auth.pyfrom local formatting/lint pass