Skip to content

Unhelpful warning is displayed when using deprecated configs #15568

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

Closed
dannykopping opened this issue Nov 18, 2024 · 1 comment · Fixed by #15581
Closed

Unhelpful warning is displayed when using deprecated configs #15568

dannykopping opened this issue Nov 18, 2024 · 1 comment · Fixed by #15581
Assignees
Labels
bug risk Prone to bugs docs Area: coder.com/docs s3 Bugs that confuse, annoy, or are purely cosmetic

Comments

@dannykopping
Copy link
Contributor

When a deprecated setting is used, a warning is posted but it doesn't indicate the flag or the env to be used, but rather its name.

PrintDeprecatedOptions() is where this is defined. We should probably print the CLI flag, env var name, or a link to the documentation.

WARN: Notifications: Email Auth: Password is deprecated, please use Email Auth: Password instead.
WARN: Telemetry (backwards compatibility) is deprecated, please use Telemetry Enable instead.
@dannykopping dannykopping added the s3 Bugs that confuse, annoy, or are purely cosmetic label Nov 18, 2024
@coder-labeler coder-labeler bot added bug risk Prone to bugs docs Area: coder.com/docs labels Nov 18, 2024
@DanielleMaywood
Copy link
Contributor

The related code is located here

coder/cli/server.go

Lines 1265 to 1297 in a2433b1

func PrintDeprecatedOptions() serpent.MiddlewareFunc {
return func(next serpent.HandlerFunc) serpent.HandlerFunc {
return func(inv *serpent.Invocation) error {
opts := inv.Command.Options
// Print deprecation warnings.
for _, opt := range opts {
if opt.UseInstead == nil {
continue
}
if opt.ValueSource == serpent.ValueSourceNone || opt.ValueSource == serpent.ValueSourceDefault {
continue
}
warnStr := opt.Name + " is deprecated, please use "
for i, use := range opt.UseInstead {
warnStr += use.Name + " "
if i != len(opt.UseInstead)-1 {
warnStr += "and "
}
}
warnStr += "instead.\n"
cliui.Warn(inv.Stderr,
warnStr,
)
}
return next(inv)
}
}
}

This could be made nicer by inspecting opt.ValueSource to see how the end user has configured the option and printing the relevant flags this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug risk Prone to bugs docs Area: coder.com/docs s3 Bugs that confuse, annoy, or are purely cosmetic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants