Add private model catalog SDK support (AddCatalog, SelectCatalog, GetCatalogNames)#601
Add private model catalog SDK support (AddCatalog, SelectCatalog, GetCatalogNames)#601kobby-kobbs wants to merge 6 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds C# SDK support for managing private model catalogs (MDS integration) by extending the catalog API surface, implementing the new interop commands, and adding tests—while also reducing the risk of credential leakage in logs.
Changes:
- Extends
ICatalogwithAddCatalogAsync,SelectCatalogAsync, andGetCatalogNamesAsync. - Implements the new catalog-management commands in
Catalog, including forced refresh behavior. - Removes logging of command input in
CoreInteroperror paths and adds AOT JSON context forList<string>.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cs/src/ICatalog.cs | Adds new public async catalog-management methods to the catalog interface. |
| sdk/cs/src/Catalog.cs | Implements add/select/list catalog operations and introduces a forceRefresh option for model updates. |
| sdk/cs/src/Detail/CoreInterop.cs | Stops logging command input in error paths to avoid leaking secrets. |
| sdk/cs/src/Detail/JsonSerializationContext.cs | Registers List<string> for source-generated JSON serialization (AOT). |
| sdk/cs/test/FoundryLocal.Tests/CatalogManagementTests.cs | Adds tests covering add/select/reset and catalog name listing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| private async Task UpdateModels(CancellationToken? ct) | ||
| private async Task UpdateModels(CancellationToken? ct, bool forceRefresh = false) |
There was a problem hiding this comment.
There is a function for invalidating the cache: InvalidateCache. Could you use that instead of adding forceRefresh?
| string? clientSecret = null, string? bearerToken = null, | ||
| string? tokenEndpoint = null, string? audience = null, |
There was a problem hiding this comment.
Can we keep only the essential arguments in the function and move all the optional arguments in a map argument.
Different catalogs may have different arguments that may be needed. So, the basic ones can be explicit arguments and the optional ones can be in a map?
| if (uri.Scheme != "https" && uri.Scheme != "http") | ||
| { | ||
| throw new ArgumentException($"Catalog URI must use http or https scheme, got '{uri.Scheme}'.", nameof(uri)); | ||
| } | ||
|
|
||
| if (tokenEndpoint != null) | ||
| { | ||
| if (!Uri.TryCreate(tokenEndpoint, UriKind.Absolute, out var parsedEndpoint)) | ||
| { | ||
| throw new ArgumentException($"Token endpoint is not a valid URL: '{tokenEndpoint}'.", nameof(tokenEndpoint)); | ||
| } | ||
| if (parsedEndpoint.Scheme != "https" && parsedEndpoint.Scheme != "http") | ||
| { | ||
| throw new ArgumentException($"Token endpoint must use http or https scheme, got '{parsedEndpoint.Scheme}'.", nameof(tokenEndpoint)); | ||
| } | ||
| } | ||
|
|
||
| await Utils.CallWithExceptionHandling(async () => | ||
| { | ||
| var request = new CoreInteropRequest | ||
| { | ||
| Params = new Dictionary<string, string> | ||
| { | ||
| ["Name"] = name, | ||
| ["Uri"] = uri.ToString(), | ||
| ["ClientId"] = clientId ?? "", | ||
| ["ClientSecret"] = clientSecret ?? "", | ||
| ["BearerToken"] = bearerToken ?? "", | ||
| ["TokenEndpoint"] = tokenEndpoint ?? "", | ||
| ["Audience"] = audience ?? "" | ||
| } | ||
| }; |
There was a problem hiding this comment.
Can all of this logic be moved to Core so each sdk need not have this logic?
Summary
ICatalog:AddCatalogAsync,SelectCatalogAsync,GetCatalogNamesAsyncChanges by file
sdk/cs/src/ICatalog.csAdds three new interface methods with full XML documentation:
AddCatalogAsync— Register a private catalog with OAuth2/bearer auth supportSelectCatalogAsync— Filter models to a specific catalog (or null to show all)GetCatalogNamesAsync— List all registered catalog namessdk/cs/src/Catalog.csImplements the three new methods with:
forceRefreshparameter onUpdateModelsso Add/Select immediately refresh the model listGetCatalogNamesAsyncsdk/cs/src/Detail/CoreInterop.csRemoves logging of
commandInputin error paths to prevent leaking credentials (client secrets, bearer tokens) in debug logs.sdk/cs/src/Detail/JsonSerializationContext.csRegisters
List<string>for AOT-compatible JSON serialization of catalog names.sdk/cs/test/FoundryLocal.Tests/CatalogManagementTests.csNew test class with two tests:
Test_AddAndSelectCatalog— Verifies add + select + reset flowTest_GetCatalogNames— Verifies catalog name retrieval and deserialization