mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
fix: skip frozen fields when applying settings payload
The secrets_store field on Settings is frozen, so setattr() raised a validation error when the POST /api/settings payload included that key. Filter out any frozen field before calling setattr in _apply_settings_payload. Added a regression test. Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -270,6 +270,21 @@ async def test_settings_api_endpoints(test_client):
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_saving_settings_with_frozen_secrets_store(test_client):
|
||||
"""Regression: POSTing settings must not fail when the payload includes
|
||||
``secrets_store`` (a frozen field on the Settings model).
|
||||
See https://github.com/OpenHands/OpenHands/issues/13306.
|
||||
"""
|
||||
settings_data = {
|
||||
'language': 'en',
|
||||
'llm_model': 'gpt-4',
|
||||
'secrets_store': {'provider_tokens': {}},
|
||||
}
|
||||
response = test_client.post('/api/settings', json=settings_data)
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_api_key_preservation(test_client):
|
||||
"""Test that search_api_key is preserved when sending an empty string."""
|
||||
|
||||
Reference in New Issue
Block a user