UN-3357 [FIX] Application logs out user upon "Test Connection" failure with invalid credentials#1888
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughIntercepts SDK errors in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
| Filename | Overview |
|---|---|
| backend/adapter_processor_v2/exceptions.py | Adds a 401→400 status-code remap in TestAdapterError to prevent the frontend Axios interceptor from treating a bad-API-key response as a session expiry. Change is well-scoped and correct. |
Sequence Diagram
sequenceDiagram
actor User
participant Frontend
participant UnstractAPI as Unstract API
participant SDK as Unstract SDK
participant Provider as LLM Provider (e.g. OpenAI)
User->>Frontend: Click "Test Connection" (invalid API key)
Frontend->>UnstractAPI: POST /test-adapter
UnstractAPI->>SDK: test_connection(credentials)
SDK->>Provider: API request with bad key
Provider-->>SDK: HTTP 401 (invalid API key)
SDK-->>UnstractAPI: SdkError(status_code=401)
Note over UnstractAPI: TestAdapterError.__init__<br/>BEFORE fix: status_code = 401<br/>AFTER fix: status_code = 400 (remapped)
UnstractAPI-->>Frontend: HTTP 400 (AFTER fix) / HTTP 401 (BEFORE fix)
alt BEFORE fix: 401 forwarded
Frontend->>Frontend: Axios interceptor sees 401 → logout user ❌
else AFTER fix: 400 returned
Frontend->>Frontend: Axios interceptor ignores 400 ✅
Frontend-->>User: Show error message (bad credentials)
end
Prompt To Fix All With AI
This is a comment left during a code review.
Path: backend/adapter_processor_v2/exceptions.py
Line: 70
Comment:
**Consider `logger.debug` instead of `logger.info`**
This log line fires on every "Test Connection" attempt with bad credentials. In a busy deployment with many users iterating on adapter configurations, logging at `INFO` level will add noise to production logs for a purely internal remapping detail. `DEBUG` is more appropriate here since the relevant user-visible information (the provider's error text) is already surfaced in the response body.
```suggestion
logger.debug("Remapping provider status code 401 to 400")
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (3): Last reviewed commit: "Merge branch 'main' into UN-3357-BUG-rc...." | Re-trigger Greptile
…-upon-Test-Connection-failure-with-invalid-credentials
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|
|



What
Why
TestAdapterErrorwas blindly forwarding the provider's status code as the Unstract API response status codeHow
TestAdapterError, instead of forwarding the provider's status code as-is, remap 401 to 400Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.