-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli: warn the user for common mistakes around options=-ccluster
#97588
Conversation
u.warnFn("\nwarning: found raw URL parameter \"%[1]s\"; "+ | ||
"are you sure you did not mean to use \"options=%[1]s\" instead?\n\n", optName) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wanted, some of the surrounding formatting could go into the warnFn to keep it consistent as we add more checks. But I don't feel strongly about it.
pkg/cli/clienturl/client_url.go
Outdated
// For tenant selection, the option is `-ccluster=`, not `-cluster=`. | ||
if extraOpts := opts.Get("options"); extraOpts != "" { | ||
if strings.Contains(extraOpts, "-cluster=") { | ||
u.warnFn("\nwarning: found \"-cluster=\" in URL \"options\" field; " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps somewhat confusingly, all of these are allowed:
-c cluster=
-ccluster=
--cluster=
i am not sure if we want to mention the other allowed syntaxes here. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify your question? -c cluster=
and -ccluster=
are equivalent (and valid)
I did not know --cluster=
. Is this one valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the point i am making is that all three of the syntaxes i listed are valid and equivalent. my question is: should our informational message mention all three of them?
(we matched the PG behavior documented at https://www.postgresql.org/docs/current/app-psql.html - look for -c command
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a separate point i just thought of: if we have to pick only one to recommend, then i think options=-ccluster=
is less clear than options=-c cluster=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-ccluster=
can be typed in without escapes (e.g. the user can literally type in &options=-ccluster=...
) whereas if we recommend a space they will have to use %20
which strains the eye.
I did not know that --cluster=
was accepted. i'll add tests for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've ended up reusing the same code as pgwire so we have consistent behavior.
de0f7f1
to
76a63d5
Compare
Examples: ``` % ./cockroach sql --url='postgres://localhost:26257/?-ccluster=foo' warning: found raw URL parameter "-ccluster"; are you sure you did not mean to use "options=-ccluster" instead? % ./cockroach sql --url='postgres://localhost:26257/?options=-cluster=foo' warning: found "-cluster=" in URL "options" field; are you sure you did not mean to use "options=-ccluster" instead? ``` Release note: None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @knz)
pkg/cli/clienturl/client_url.go
line 299 at r1 (raw file):
Previously, knz (Raphael 'kena' Poss) wrote…
i've ended up reusing the same code as pgwire so we have consistent behavior.
that sgtm! thank you
TFYR! bors r=rafiss |
Build failed: |
bors r=rafiss |
Build failed: |
bors r=rafiss |
Build failed: |
bors r=rafiss |
Build succeeded: |
Fixes #97586.
Epic: CRDB-23559
Examples:
Release note: None