{"record":{"id":"ac751e7326318754","repo":"AlistGo/alist","slug":"invalid-url-format-w","errorCode":null,"errorMessage":"invalid URL format: %w","messagePattern":"invalid URL format: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/doubao/util.go","lineNumber":157,"sourceCode":"\treturn resp, err\n}\n\nfunc (d *Doubao) getUserInfo() (UserInfo, error) {\n\tvar r UserInfoResp\n\n\t_, err := d.request(\"/passport/account/info/v2/\", http.MethodGet, nil, &r)\n\tif err != nil {\n\t\treturn UserInfo{}, err\n\t}\n\n\treturn r.Data, err\n}\n\n// 签名请求\nfunc (d *Doubao) signRequest(req *resty.Request, method, tokenType, uploadUrl string) error {\n\tparsedUrl, err := url.Parse(uploadUrl)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid URL format: %w\", err)\n\t}\n\n\tvar accessKeyId, secretAccessKey, sessionToken string\n\tvar serviceName string\n\n\tif tokenType == VideoDataType {\n\t\taccessKeyId = d.UploadToken.Samantha.StsToken.AccessKeyID\n\t\tsecretAccessKey = d.UploadToken.Samantha.StsToken.SecretAccessKey\n\t\tsessionToken = d.UploadToken.Samantha.StsToken.SessionToken\n\t\tserviceName = \"vod\"\n\t} else {\n\t\taccessKeyId = d.UploadToken.Alice[tokenType].Auth.AccessKeyID\n\t\tsecretAccessKey = d.UploadToken.Alice[tokenType].Auth.SecretAccessKey\n\t\tsessionToken = d.UploadToken.Alice[tokenType].Auth.SessionToken\n\t\tserviceName = \"imagex\"\n\t}\n\n\t// 当前时间，格式为 ISO8601","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/doubao/util.go#L139-L175","documentation":"signRequest parses the upload URL (uploadUrl) with url.Parse before building the Volcengine-style V4 signature for the upload host. If parsing fails the operation aborts before signing. In practice url.Parse almost never fails on absolute URLs, so this error usually signals a corrupted upload URL received from the upload-config endpoint (control characters, empty string edge cases, or malformed host from server config).","triggerScenarios":"uploadUrl built from uploadNode.UploadHost + storeInfo.StoreURI contains characters url.Parse rejects (control chars, spaces in odd places), or the config endpoint returned empty/garbage host fields that produced an unparseable URL string.","commonSituations":"Doubao backend returning unexpected upload host values after an app update; a token type (Alice vs Samantha) mapping to missing keys, producing malformed URL construction upstream; proxy or middleware mangling the URL string.","solutions":["Log the uploadUrl value when this fires — the parse error text pinpoints the offending characters","If the URL is empty or truncated, the upload token/config fetch above it is the real failure; refresh the upload token (initUploadToken) and retry","Report upstream if the provider consistently returns hosts that fail standard URL parsing"],"exampleFix":"// before\nparsedUrl, err := url.Parse(uploadUrl)\nif err != nil {\n\treturn fmt.Errorf(\"invalid URL format: %w\", err)\n}\n// after\nparsedUrl, err := url.Parse(uploadUrl)\nif err != nil {\n\treturn fmt.Errorf(\"invalid upload URL %q: %w\", uploadUrl, err)\n}","handlingStrategy":"validation","validationCode":"parsed, err := url.Parse(uploadUrl)\nif err != nil || parsed.Scheme == \"\" || parsed.Host == \"\" {\n\treturn fmt.Errorf(\"upload URL %q is not absolute and parseable\", uploadUrl)\n}","typeGuard":"func isUsableUploadURL(u string) bool {\n\tp, err := url.Parse(u)\n\treturn err == nil && (p.Scheme == \"http\" || p.Scheme == \"https\") && p.Host != \"\"\n}","tryCatchPattern":"if strings.Contains(err.Error(), \"invalid URL format\") {\n\t// upstream config is corrupt: refresh upload token/config and retry once\n}","preventionTips":["Validate upload URLs for scheme+host before signing","Re-fetch upload config when host fields look empty","Report recurring malformed hosts upstream"],"tags":["doubao","upload","url-parsing","signing"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}