Skip to content

Fixes #250 - Dotnet SDK Validate Session Config Model#378

Open
john-mckillip wants to merge 4 commits intogithub:mainfrom
john-mckillip:bugfix/dotnet-sdk-validate-session-config-model
Open

Fixes #250 - Dotnet SDK Validate Session Config Model#378
john-mckillip wants to merge 4 commits intogithub:mainfrom
john-mckillip:bugfix/dotnet-sdk-validate-session-config-model

Conversation

@john-mckillip
Copy link

This pull request improves model validation when creating Copilot sessions and enhances test coverage to ensure invalid models are handled correctly. The main changes focus on validating the provided model ID and updating tests to reflect this new behavior.

Model validation improvements:

  • Added validation in Client.cs to check if the specified Model in SessionConfig exists among the available models. If the model is invalid, an ArgumentException is thrown with a clear error message.

Test updates:

  • Updated the test in SessionTests.cs to use a valid model name (claude-sonnet-4.5) instead of a placeholder.
  • Added a new test to verify that CreateSessionAsync throws an ArgumentException when called with an invalid model name, and that the error message contains relevant details.

Validate that SessionConfig.Model is a valid model name before creating
a session. When an invalid model is specified, throw an ArgumentException
with the invalid model name and list of available models.

Fixes github#250
@john-mckillip john-mckillip requested a review from a team as a code owner February 5, 2026 02:46
Copilot AI review requested due to automatic review settings February 5, 2026 02:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds model validation to the .NET SDK's CreateSessionAsync method to ensure that only valid model IDs are used when creating sessions. The implementation throws an ArgumentException with a helpful error message listing available models when an invalid model is specified.

Changes:

  • Added validation logic in Client.cs to verify the model ID exists in the list of available models before creating a session
  • Updated existing test to use a valid model name (claude-sonnet-4.5) instead of a placeholder
  • Added new test to verify that invalid model names trigger an ArgumentException with appropriate error details

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dotnet/src/Client.cs Implements model validation by checking the provided model against available models and throwing ArgumentException if invalid
dotnet/test/SessionTests.cs Updates test with valid model name and adds new test case for invalid model validation

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.

1 participant