dsn: document that usernames containing colons require NewConfig()#1768
dsn: document that usernames containing colons require NewConfig()#1768nghiack7 wants to merge 1 commit into
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThe PR expands ChangesDSN Documentation Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.1)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hmmm... As @methane says, I recommend using |
|
Thank you for the review @shogo82148 and for linking the maintainer's recommendation. You're correct — using the last colon before Both interpretations are valid reads of the DSN format, so the DSN syntax itself is fundamentally ambiguous for this case. There is no unambiguous fix within Given @methane's recommendation to use
Happy to update to option 2 if that would be accepted, or close if the preference is to keep |
The DSN format uses ':' as the user/password separator, making it impossible to represent a username that contains a colon without ambiguity. There is no safe way to fix this in ParseDSN without breaking existing users who rely on the current first-colon behaviour for passwords that contain colons. Instead, document the limitation clearly in the ParseDSN godoc and point callers to NewConfig(), which has no such ambiguity. Fixes go-sql-driver#1747
bff59f9 to
4825420
Compare
|
It seems odd that the DSN has many constraints, but only the characters that cannot be used in the username are mentioned. It gives the impression that there are no other major constraints. Additonally, would it be appropriate to write about the design and constraints of the DSN in the docstring of this function? I think it would be better to add a section about the DSN in doc.go. |
|
ja: このコメントでは実験的に、日本語と英語を両方記述しています。私は英文を書くのが苦手でAIに頼っていますが、元の日本語の文章にも価値があると考えているからです。 ja: 私はDSNをURIに近づけたいと思っています。 username と password は %-encode されるべきです。 tcp() は省略可能にするべきです。しかし、すでにusernameかpasswordに%が入っている場合に後方互換性を失うことになります。他にも後方互換性が失われるケースがあるかもしれませんが、まだ深く考えていません。 ja: 過去のマイナーバージョンでも、より正しい動作をするために幾らかの後方互換性を犠牲にすることは許容してきました。API互換性を破壊しないのであれば、v2をリリースするよりも、少しの振る舞いの変更をユーザーに受け入れてもらう方が総合的にはいいと考えます。 ja: もう一つのアイデアは完全に新しいDSNを |
Updated Approach
After the maintainer review (thank you @shogo82148 and @methane), I've updated this PR to be documentation-only — no behavioral change.
What changed
Added a godoc note to
ParseDSNexplaining the fundamental ambiguity:Why this approach
The original fix (last colon) broke passwords containing colons — a symmetric bug to the one it was fixing. There is no unambiguous parse rule for the
user:password@portion when either field can contain a colon.The correct solution is to steer users to
NewConfig(), which has no such ambiguity.Fixes #1747