You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NpgsqlConnectionStringBuilder.Remove and Clear leave Encoding and Kerberos Service Name in the connection string #6724
varbuilder=newNpgsqlConnectionStringBuilder("Host=myhost;Encoding=LATIN1;Kerberos Service Name=foo");builder.Remove("Encoding");builder.Remove("Kerberos Service Name");Console.WriteLine(builder.ConnectionString);builder=newNpgsqlConnectionStringBuilder("Host=myhost;Encoding=LATIN1");builder.Clear();Console.WriteLine($"{builder.Count} '{builder.ConnectionString}'");
The issue
Remove doesn't remove these two keys. It replaces them with their default values, so the first line prints Host=myhost;Encoding=UTF8;Kerberos Service Name=postgres instead of Host=myhost. Clear() leaves one key, so the second line prints 1 'Encoding=UTF8' instead of 0 ''. Setting builder["Encoding"] = null behaves the same way.
Other properties, such as SSL Mode and Command Timeout, are removed as expected. The difference is that Encoding and Kerberos Service Name are string properties with a non-null default value.
Further technical details
Npgsql version: main at b35800b
PostgreSQL version: not relevant (no connection is opened)
Operating system: Linux x86_64
Other details about my project setup: .NET SDK 10.0.403
Activity
vonzshik commentedon Nov 17, 2026
Yep, seems to have broke when we were improving AOT size (around .NET 8 I think?).
@lqkhanh295 could you please post anything here so I can assign this issue to you?
lqkhanh295 commentedon Nov 17, 2026
Hi @vonzshik, thanks for reviewing! Commenting here as requested so you can assign the issue.