{"record":{"id":"be87b5e44cfd671f","repo":"benbjohnson/litestream","slug":"cannot-expand-home-directory-for-sse-customer-key","errorCode":null,"errorMessage":"cannot expand home directory for sse-customer-key-path: %w","messagePattern":"cannot expand home directory for sse-customer-key-path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/main.go","lineNumber":1696,"sourceCode":"\tif c.Concurrency != nil {\n\t\tclient.Concurrency = *c.Concurrency\n\t}\n\n\t// Apply SSE-C configuration if specified.\n\tif c.SSECustomerKey != \"\" || c.SSECustomerKeyPath != \"\" {\n\t\tclient.SSECustomerAlgorithm = c.SSECustomerAlgorithm\n\t\tif client.SSECustomerAlgorithm == \"\" {\n\t\t\tclient.SSECustomerAlgorithm = \"AES256\"\n\t\t}\n\n\t\t// Read key from file if path is specified, otherwise use direct value.\n\t\tif c.SSECustomerKeyPath != \"\" {\n\t\t\tkeyPath := c.SSECustomerKeyPath\n\t\t\t// Expand ~ to home directory\n\t\t\tif strings.HasPrefix(keyPath, \"~\") {\n\t\t\t\thome, err := os.UserHomeDir()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"cannot expand home directory for sse-customer-key-path: %w\", err)\n\t\t\t\t}\n\t\t\t\tkeyPath = home + keyPath[1:]\n\t\t\t}\n\t\t\tkeyData, err := os.ReadFile(keyPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"cannot read sse-customer-key-path %q: %w\", c.SSECustomerKeyPath, err)\n\t\t\t}\n\t\t\tclient.SSECustomerKey = strings.TrimSpace(string(keyData))\n\t\t} else {\n\t\t\tclient.SSECustomerKey = c.SSECustomerKey\n\t\t}\n\t}\n\n\t// Apply SSE-KMS configuration if specified.\n\tif c.SSEKMSKeyID != \"\" {\n\t\tclient.SSEKMSKeyID = c.SSEKMSKeyID\n\t}\n","sourceCodeStart":1678,"sourceCodeEnd":1714,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/main.go#L1678-L1714","documentation":"Wraps os.UserHomeDir() failure while expanding a leading '~' in the s3 sse-customer-key-path config option. Fires when the path starts with '~' but the user's home directory cannot be determined (e.g. HOME not set in the environment); the SSE-C key file cannot be located.","triggerScenarios":"Thrown at cmd/litestream/main.go:1696 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set HOME (or USERPROFILE on Windows) in the service environment","Use an absolute path for sse-customer-key-path instead of '~'"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}