fix: move /change-model credentials from query params to request body#107
Open
zikunz wants to merge 1 commit intosugarlabs:mainfrom
Open
fix: move /change-model credentials from query params to request body#107zikunz wants to merge 1 commit intosugarlabs:mainfrom
zikunz wants to merge 1 commit intosugarlabs:mainfrom
Conversation
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.
The
/change-modelendpoint acceptsapi_keyandpasswordas URL query parameters (Query(...)). This means credentials appear in server access logs, browser history, proxy caches, and HTTP Referer headers. Sugar-AI is a children's education platform, making credential exposure especially sensitive.Before:
After:
Solution
ChangeModelRequestPydantic model withmin_length=1validation on all fields, consistent with the pattern used byPromptedLLMRequest/change-modelhandler to read from the JSON request body instead of URL query parameterswelcome.htmlandREADME.mdto show JSON body usage</ul>tag inwelcome.htmlthat had no matching<ul>(pre-existing)Queryimport and clean up trailing whitespace on blank lines in the handlerNo changes to business logic, authentication flow, or response format.
Note: This is a breaking change for callers that pass credentials as query parameters. They will need to switch to sending a JSON request body. The deployed Sugar-AI instance currently has no known external callers of this admin-only endpoint beyond the development team.
Related: #87 applies the same pattern to the
/debugendpoint. These two changes are independent and do not conflict.Testing
Verified that:
POST /change-modelwith JSON body{"model": "...", "api_key": "...", "password": "..."}works correctlymodel,api_key, orpasswordreturns HTTP 422 with validation error