Repository navigation
Validate enum values parsed from numeric strings in SqliteConnectionStringBuilder - #39654
Merged
AndriySvyryd merged 1 commit intoNov 17, 2026
Conversation
…lder ConvertToEnum returned Enum.Parse's result for strings without the Enum.IsDefined check applied to every other input. Enum.Parse accepts numeric strings and comma-separated names, so "Mode=42", "Cache=42" or "Synchronous=7" were accepted, while the integer 42 was rejected. An undefined Mode silently opened the database as ReadWriteCreate (and failed a Debug.Assert), an undefined Cache was ignored, and an undefined Synchronous value was sent as PRAGMA synchronous. Run the string result through the same validation.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The enum-validation changes are accompanied by regression coverage for invalid numeric and comma-separated values across the affected options, with no active review issues reported.
No open issues 🎉
What changed in this PR
This pull request fixes inconsistent enum validation in SqliteConnectionStringBuilder by applying Enum.IsDefined to values parsed from strings, preventing undefined numeric and comma-separated enum values from being accepted.
Changes:
- Validates parsed string enum values before assigning connection options.
- Adds regression coverage for invalid numeric and comma-separated values across
Mode,Cache, andSynchronous.
| File | Description |
|---|---|
| test/Microsoft.Data.Sqlite.Tests/SqliteConnectionStringBuilderTest.cs | Adds regression tests covering invalid numeric and comma-separated string enum values. |
| src/Microsoft.Data.Sqlite.Core/SqliteConnectionStringBuilder.cs | Applies defined-value validation to enum values parsed from connection strings. |
Review effort: Lite
AndriySvyryd
approved these changes
Nov 17, 2026
AndriySvyryd
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!
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.
ConvertToEnum returned Enum.Parse's result for strings without the Enum.IsDefined check applied to every other input. Enum.Parse accepts numeric strings and comma-separated names, so "Mode=42", "Cache=42" or "Synchronous=7" were accepted, while the integer 42 was rejected.
An undefined Mode silently opened the database as ReadWriteCreate (and failed a Debug.Assert), an undefined Cache was ignored, and an undefined Synchronous value was sent as PRAGMA synchronous.
Run the string result through the same validation.