{"record":{"id":"ecaadf3758cf0265","repo":"AlistGo/alist","slug":"addr-is-nil","errorCode":null,"errorMessage":"addr is nil","messagePattern":"addr is nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/halalcloud/util.go","lineNumber":223,"sourceCode":"\t}\n\treturn opPath\n}\n\nfunc (d *HalalCloud) GetCurrentDir(dir model.Obj) string {\n\tcurrentDir := dir.GetPath()\n\tif len(currentDir) == 0 {\n\t\tcurrentDir = \"/\"\n\t}\n\treturn currentDir\n}\n\ntype Common struct {\n}\n\nfunc getRawFiles(addr *pubUserFile.SliceDownloadInfo) ([]byte, error) {\n\n\tif addr == nil {\n\t\treturn nil, errors.New(\"addr is nil\")\n\t}\n\n\tclient := http.Client{\n\t\tTimeout: time.Duration(60 * time.Second), // Set timeout to 5 seconds\n\t}\n\tresp, err := client.Get(addr.DownloadAddress)\n\tif err != nil {\n\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"bad status: %s, body: %s\", resp.Status, body)\n\t}","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/halalcloud/util.go#L205-L241","documentation":"getRawFiles dereferences a *pubUserFile.SliceDownloadInfo describing where to fetch slice bytes; a nil pointer means the caller passed no download address at all. Guarding prevents a panic at addr.DownloadAddress. It fires before the 60-second http.Client GET, so no network I/O has happened.","triggerScenarios":"HalalCloud list/download path hands a nil SliceDownloadInfo to getRawFiles — typically the file metadata from the gRPC response had no download info populated (file still processing, server returned nil field) or a lookup returned nil and was passed unchecked.","commonSituations":"Downloading a just-uploaded file whose slices are not ready server-side; server-side outage returning incomplete metadata; code path assumes addr is always present after a range/list call that actually returned an error the caller ignored.","solutions":["In the caller, verify the SliceDownloadInfo field is non-nil (and DownloadAddress non-empty) before invoking getRawFiles","If nil because the file is processing, wait/retry until the server populates download info","Capture the raw gRPC response for the failing file to confirm whether download info was ever sent"],"exampleFix":"// before\ninfo := resp.File.SliceDownloadInfo\nraw, err := getRawFiles(info)\n// after\nif resp.File == nil || resp.File.SliceDownloadInfo == nil {\n\treturn fmt.Errorf(\"file %s has no download info yet\", name)\n}\nraw, err := getRawFiles(resp.File.SliceDownloadInfo)","handlingStrategy":"type-guard","validationCode":"if info == nil || strings.TrimSpace(info.DownloadAddress) == \"\" {\n\treturn fmt.Errorf(\"slice download info unavailable for this file; retry after processing completes\")\n}","typeGuard":"func hasDownloadInfo(info *pubUserFile.SliceDownloadInfo) bool {\n\treturn info != nil && strings.TrimSpace(info.DownloadAddress) != \"\"\n}","tryCatchPattern":null,"preventionTips":["Check server metadata fields for nil before every dereference in driver adapters","Treat missing download info on a fresh upload as 'processing', not an error: retry with backoff"],"tags":["halalcloud","nil-check","download","driver","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}