fix: Clears api_base in config when cleared from frontend settings page#762
Open
rohankshah wants to merge 1 commit into
Open
fix: Clears api_base in config when cleared from frontend settings page#762rohankshah wants to merge 1 commit into
rohankshah wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/backend/app/routers/config.py">
<violation number="1" location="apps/backend/app/routers/config.py:138">
P2: PUT config update now clears `api_base` when omitted, causing unintended loss of saved base URL on partial updates.</violation>
</file>
<file name="apps/backend/tests/integration/test_config_api.py">
<violation number="1" location="apps/backend/tests/integration/test_config_api.py:55">
P2: The test does not persist state between requests, so it cannot verify that a stale `api_base` is actually cleared across reloads.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if request.api_base is not None: | ||
| stored["api_base"] = request.api_base | ||
|
|
||
| stored["api_base"] = request.api_base if request.api_base is not None else "" |
Contributor
There was a problem hiding this comment.
P2: PUT config update now clears api_base when omitted, causing unintended loss of saved base URL on partial updates.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/backend/app/routers/config.py, line 138:
<comment>PUT config update now clears `api_base` when omitted, causing unintended loss of saved base URL on partial updates.</comment>
<file context>
@@ -134,8 +134,9 @@ async def update_llm_config(
- if request.api_base is not None:
- stored["api_base"] = request.api_base
+
+ stored["api_base"] = request.api_base if request.api_base is not None else ""
+
if request.reasoning_effort is not None:
</file context>
Suggested change
| stored["api_base"] = request.api_base if request.api_base is not None else "" | |
| if request.api_base is not None: | |
| stored["api_base"] = request.api_base |
| @@ -46,6 +46,34 @@ async def test_put_llm_config(self, mock_load, mock_save, client): | |||
| data = resp.json() | |||
Contributor
There was a problem hiding this comment.
P2: The test does not persist state between requests, so it cannot verify that a stale api_base is actually cleared across reloads.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/backend/tests/integration/test_config_api.py, line 55:
<comment>The test does not persist state between requests, so it cannot verify that a stale `api_base` is actually cleared across reloads.</comment>
<file context>
@@ -46,6 +46,34 @@ async def test_put_llm_config(self, mock_load, mock_save, client):
+ async def test_put_llm_config_api_base_clears(self, mock_log, mock_load, mock_save, client):
+ # Simulate storage
+ stored = {}
+ mock_load.side_effect = lambda: stored.copy()
+
+ async with client:
</file context>
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.
Pull Request Title
Clears api_base in config when cleared from frontend settings page
Related Issue
#760
Description
A stale value for
api_basepersisted in the config after adding it and removing it. This made it impossible for the user to clear it.Type
Proposed Changes
Set the
api_basevalue to empty string even when the request doesn't haveapi_basevalueAdded a test case to
apps/backend/tests/integration/test_config_api.pyHow to Test
Base Urlvalue to the llm provider and click SaveBase Urlvalue and click Save.Checklist
Summary by cubic
Fixes stale
api_basevalues in config when users clear the Base URL in the settings UI. Clearing now persists correctly so users can remove a custom base URL.api_baseto an empty string when the request omits it inupdate_llm_config.api_basevia/api/v1/config/llm-api-key.Written for commit 01463b3. Summary will update on new commits.