-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
coder config-ssh --ssh-host-prefix="" or CODER_CONFIGSSH_SSH_HOST_PREFIX= doesn't allow excluding the legacy Host coder.* SSH config block. Setting an empty value is treated as "not set" and defaults to the server's HostnamePrefix (typically coder.).
This causes conflicts with the newer --hostname-suffix approach. Users who only want the suffix-based config (e.g., *.coder) cannot remove the legacy prefix-based Host coder.* block without manually editing their SSH config.
Root Cause
In cli/configssh.go, the mergeSSHOptions function (lines 605-610):
if user.userHostPrefix == "" {
configOptions.userHostPrefix = coderd.HostnamePrefix
}
if user.hostnameSuffix == "" {
configOptions.hostnameSuffix = coderd.HostnameSuffix
}Empty string ("") is treated as "not set", falling back to server defaults. Serpent correctly tracks ValueSource for options, but this logic doesn't distinguish between "flag not provided" and "flag explicitly set to empty".
Suggested Fix
Track whether the flag was explicitly provided (via serpent's Option.ValueSource or pflag's .Changed) and only apply the server default when the flag was not provided at all:
// Only apply server default if user didn't explicitly set the flag
if user.userHostPrefix == "" && !userHostPrefixExplicitlySet {
configOptions.userHostPrefix = coderd.HostnamePrefix
}Alternatively, use a sentinel value (though that's less clean).
Related
Same issue likely applies to --hostname-suffix.