hashicorp/terraform · error
Cannot quote scp command, target platform unknown: %s
Error message
Cannot quote scp command, target platform unknown: %s
What it means
Returned by quoteScpCommand when target_platform is neither TargetPlatformUnix nor TargetPlatformWindows. The function selects shell-quoting rules per platform (POSIX vs Windows ArgvSplit); any other value has no quoting strategy and is rejected before constructing the scp command.
Source
Thrown at internal/communicator/ssh/communicator.go:898
net.Conn
Bastion *ssh.Client
}
func (c *bastionConn) Close() error {
c.Conn.Close()
return c.Bastion.Close()
}
func quoteScpCommand(args []string, targetPlatform string) (string, error) {
if targetPlatform == TargetPlatformUnix {
return shquot.POSIXShell(args), nil
}
if targetPlatform == TargetPlatformWindows {
cmd, args := shquot.WindowsArgvSplit(args)
return fmt.Sprintf("%s %s", cmd, args), nil
}
return "", fmt.Errorf("Cannot quote scp command, target platform unknown: %s", targetPlatform)
}
View on GitHub (pinned to d32a084675)
Solutions
- Set target_platform to either "unix" or "windows" (or omit it for the unix default).
- If constructing connectionInfo programmatically, always go through parseConnectionInfo so defaults and validation apply.
- Treat this error as a bug if it appears with a standard config — it indicates an internal invariant was violated.
Example fix
// before
connection {
host = aws_instance.web.public_ip
target_platform = "linux"
}
// after
connection {
host = aws_instance.web.public_ip
target_platform = "unix"
} Defensive patterns
Strategy: type-guard
Validate before calling
# This only fires if an internal invariant is broken; ensure configs use # parseConnectionInfo which validates target_platform to unix/windows. # In HCL: target_platform = "unix" | "windows" (or omit).
Type guard
// Go guard before quoting if constructing commands outside the helper:
func validTargetPlatform(p string) bool {
return p == "unix" || p == "windows"
} Prevention
- Always set target_platform to 'unix' or 'windows' or omit it.
- Construct connectionInfo only through parseConnectionInfo so defaults/validation apply.
- Report as a bug if it appears with standard config.
When it happens
Trigger: An explicit target_platform value that bypassed parseConnectionInfo's validation (e.g. set programmatically to 'mac', 'linux', or empty-but-not-defaulted through a non-standard path). Normally parseConnectionInfo defaults '' to unix and rejects anything else, so this is a defense-in-depth guard.
Common situations: A custom provisioner/communicator wrapper setting TargetPlatform directly; a malformed connectionInfo struct constructed outside parseConnectionInfo; a future code path that adds a platform constant without updating quoteScpCommand.
Related errors
- connection type '%s' not supported
- Error reading error message: %s
- Error creating temporary file for upload: %s
- host for provisioner cannot be empty
- target_platform for provisioner has to be either %s or %s
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/7fa7e0aef063c122.
Report an issue: GitHub.