fix(admin): use static error messages in excluded models/providers handlers#528
Open
rohith500 wants to merge 1 commit into
Open
fix(admin): use static error messages in excluded models/providers handlers#528rohith500 wants to merge 1 commit into
rohith500 wants to merge 1 commit into
Conversation
…ndlers handlers were returning err.Error() directly on unknown model/provider 400 responses, which leaked the internal Go package name prefix 'auth:' to the client (e.g. 'auth: unknown model id: "..."'). All other error responses in the admin API use static strings; align these two handlers with that pattern. Verified live: before returns 'auth: unknown model id: ...', after returns 'unknown model id in exclusion list'. Fixes: internal/api/admin/excluded_models.go:127 Fixes: internal/api/admin/excluded_providers.go:113 Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com>
|
PR author is not in the allowed authors list. |
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.
Problem
PUT /admin/v1/excluded-modelsandPUT /admin/v1/excluded-providerscallerr.Error()directly when an unknown model or provider name is submitted, leaking the internal Go package name prefix to the client:{"error":"auth: unknown model id: \"some-model-name\""} {"error":"auth: unknown provider: \"some-provider-name\""}The
auth:prefix comes fromErrUnknownModel = errors.New("auth: unknown model id")andErrUnknownProvider = errors.New("auth: unknown provider")ininternal/auth/service.go. These sentinel errors are internal bookkeeping — theirError()string was never intended to be user-facing.Every other 400 response in the admin API uses a static string:
These two handlers are the only ones in the admin layer that pass
err.Error()through to the client on a validation failure.Fix
Replace the two
err.Error()calls with static strings consistent with the rest of the admin API:The underlying
errors.Is(err, auth.ErrUnknownModel)/errors.Is(err, auth.ErrUnknownProvider)check is preserved — only the response body changes.Verification
Before the fix:
After the fix:
make check— all 30 packages pass. fixes #535