Skip to content

fix(openapi): leave a model's api key and endpoint out of the model lists - #1514

Merged
yileicn merged 1 commit into
SciSharp:masterfrom
yuyixg:fix/llm-config-api-hide-keys
Nov 25, 2026
Merged

yileicn merged 1 commit into
SciSharp:masterfrom
yuyixg:fix/llm-config-api-hide-keys

Conversation

@yuyixg

@yuyixg yuyixg commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Problem

GET /llm-configs and GET /llm-provider/{provider}/models return the LlmModelSetting objects bound from LlmProviders as they are, so ApiKey and Endpoint go out in the response. Both actions only require a signed-in user ([Authorize]), so any user can read the api key of every configured model.

The settings page (GET /setting/LlmProviders) already masks both fields through LlmProviderPlugin.MaskSettings; these two lists did not.

Change

  • LlmModelSetting.WithoutCredentials() returns a copy with ApiKey empty and Endpoint null. Everything else is kept (type, capabilities, reasoning, image, audio, cost...), so clients that pick a model from these lists see the same data as before.
  • LlmProviderSetting.WithoutCredentials() does the same for every model of a provider.
  • LlmProviderController returns these copies from both actions. They are copies, so the settings the providers call the models with keep their key and endpoint, even if ILlmProviderService hands out shared instances.

The BotSharp UI reads these two endpoints only to list providers and models; it does not use api_key or endpoint.

Testing

  • New LlmProviderControllerTests:
    • Neither list carries the key or the endpoint, either in the returned objects or in the serialized JSON.
    • The other fields are kept.
    • The service's own instances still have both fields afterwards.
    • Both tests fail without the change.
  • BotSharp.Core.UnitTests: 565 passed, 1 failed. The failure is SharpCacheAgentMemoryTests.GetAgent_caches_per_scope_without_adding_shared_cache_entries, which fails the same way on master without this change.

🤖 Generated with Claude Code

…ists

GET /llm-configs and GET /llm-provider/{provider}/models returned the LlmModelSetting objects as bound from
LlmProviders, ApiKey and Endpoint included, so any signed-in user could read every model's key. The settings page
(/setting/LlmProviders) already masks both through LlmProviderPlugin.MaskSettings; these two lists did not.

- LlmModelSetting.WithoutCredentials / LlmProviderSetting.WithoutCredentials: a copy with ApiKey empty and Endpoint
  null; everything else (capabilities, reasoning, image, cost...) is kept.
- LlmProviderController returns those copies. The settings the providers call the models with are not touched.

Tests:
- LlmProviderControllerTests: neither list carries the key or the endpoint, in the objects or the serialized JSON,
  and the service's own instances keep both; both tests fail without the change.
- BotSharp.Core.UnitTests: 565 passed, 1 failed (SharpCacheAgentMemoryTests.GetAgent_caches_per_scope_without_adding_shared_cache_entries,
  which fails the same way on master without this change).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@yileicn
yileicn requested a lite review from Copilot November 25, 2026 02:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@yileicn

yileicn commented Nov 25, 2026

Copy link
Copy Markdown
Member

reviewed

@yileicn
yileicn merged commit 0257037 into SciSharp:master Nov 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants