Repository navigation
Conversation
…validation OrgService.update_org_with_permissions wrapped every exception from OrgStore.update_org in OrgDatabaseError, so SDK validation failures (LLMContextWindowTooSmallError, pydantic ValidationError) reached the admin as a generic 500. OrgStore._merge_and_validate_settings now raises OrgSettingsValidationError with the message, field and limits; the service lets it through and both org settings routes answer 422. Fixes #1530 Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
|
📁 PR Artifacts Notice This PR contains a
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
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.
This PR was created by an AI agent (OpenHands) on behalf of @neubig.
HUMAN:
AGENT:
Why
OrgService.update_org_with_permissionswrapped every exception fromOrgStore.update_orginOrgDatabaseError. That included SDK validation errors, such asLLMContextWindowTooSmallErrorfor a model whose context window is below 16,384 tokens, or a pydanticValidationErrorfor a bad field type.PATCH /api/organizations/{org_id}/settingsthen answered 500 "Failed to update organization defaults settings". The admin could not tell what was wrong or how to fix it.PATCH /api/organizations/{org_id}had the same problem.Summary
OrgStore._merge_and_validate_settingsnow turnsLLMContextWindowTooSmallErrorand pydanticValidationErrorinto a newOrgSettingsValidationError. Itsdetailhas amessage, thefield, and, for the context window,context_windowandmin_required.OrgService.update_org_with_permissionsletsOrgSettingsValidationErrorthrough instead of wrapping it inOrgDatabaseError.detail. The frontend already showsdetail.messagein the save-error toast (retrieveAxiosErrorMessage).OrgSettingsValidationErroris aValueError, soPOST /api/organizations/app(which already mapsValueErrorto 400) now also returns the reason for a too-small context window instead of 500.tests/unit/server/routes/test_org_settings_validation.py. They call the real routes,OrgService,OrgStoreand SDK validation on the PostgreSQL test database. Only authentication and the LiteLLM key-rotation dependency are overridden.Issue Number
Fixes #1530
How to Test
The screenshots also run the repro test from the issue (not committed), which prints each response.
Video/Screenshots
Before: with the four source files from main, a too-small context window and a bad field type both return 500 with a generic message. All five tests fail.
After: on this branch the same requests return 422. The body names the field and the 16,384-token minimum. Nothing is saved, and a supported value still saves with 200.
Type
Notes
.pr/1530/screenshots are temporary PR artifacts. They are removed on approval.fieldis the pydantic location under the settings diff. For agent settings it includes the union tag, for exampleagent_settings_diff.openhands.llm.temperature.OrgProfilesService), not this route, so a UI capture would not exercise this code path. The screenshots show the backend tests instead.Enterprise server image for this PR: