{"record":{"id":"2b2028a9cb535524","repo":"AlistGo/alist","slug":"not-find-s-function","errorCode":null,"errorMessage":"not find %s function","messagePattern":"not find (.+?) function","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/lanzou/help.go","lineNumber":240,"sourceCode":"\tblock := make([]string, len(indexs))\n\tfor i, next := len(indexs)-1, len(html); i >= 0; i-- {\n\t\tindex := indexs[i]\n\t\tblock[i] = html[index[1]:next]\n\t\tnext = index[0]\n\t}\n\treturn strings.Join(block, \"\")\n}\n\n// 根据名称获取方法\nfunc getJSFunctionByName(html string, name string) (string, error) {\n\tindexs := findJSFunctionIndex(html, true)\n\tfor _, index := range indexs {\n\t\tdata := html[index[0]:index[1]]\n\t\tif regexp.MustCompile(`function\\s+` + name + `[()\\s]+{`).MatchString(data) {\n\t\t\treturn data, nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"not find %s function\", name)\n}\n\n// 解析html中的JSON,选择最长的数据\nfunc htmlJsonToMap2(html string) (map[string]string, error) {\n\tdatas := findDataReg.FindAllStringSubmatch(html, -1)\n\tvar sData string\n\tfor _, data := range datas {\n\t\tif len(datas) > 0 && len(data[1]) > len(sData) {\n\t\t\tsData = data[1]\n\t\t}\n\t}\n\tif sData == \"\" {\n\t\treturn nil, fmt.Errorf(\"not find data\")\n\t}\n\treturn jsonToMap(sData, html), nil\n}\n\n// 解析html中的JSON","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/lanzou/help.go#L222-L258","documentation":"getJSFunctionByName scans the JS blocks of a LanZou HTML page for a function with the requested name (matched via `function\\s+<name>[()\\s]+{`) and none matched. The page structure differs from what the driver expects, so the downstream HTML-parsing step cannot proceed.","triggerScenarios":"LanZou changes or removes the JS function the driver relies on to derive page logic (typical targets are the obfuscation/data functions on file share pages); page serves a challenge or error template with no such function.","commonSituations":"LanZou frontend redesign; A/B or gray-scale deployments serving different page variants; share link type the helper does not handle (e.g. a note/file variant) reaching the code path.","solutions":["Update OpenList to the latest release — lanzou page parsing is fixed repeatedly as LanZou changes","Open the share URL in a browser and confirm it is a normal file page; if it shows an error/verify page, handle that first (password, rate-limit)","Report the page HTML (debug log) upstream so the function-name regex is updated"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"func hasJSFunction(html, name string) bool {\n    for _, idx := range findJSFunctionIndex(html, true) {\n        if regexp.MustCompile(`function\\s+` + name + `[()\\s]+{`).MatchString(html[idx[0]:idx[1]]) {\n            return true\n        }\n    }\n    return false\n}","tryCatchPattern":"fn, err := getJSFunctionByName(html, name)\nif err != nil {\n    // page variant changed; retry after delay or fail with the page snippet for diagnosis\n    return fmt.Errorf(\"lanzou page missing function %q (frontend change?): %w\", name, err)\n}","preventionTips":["Confirm share pages render normally in a browser before automating","Pin driver versions known to work with the current LanZou frontend","Report upstream when the function disappears — parser fixes are time-sensitive"],"tags":["lanzou","scraping","parsing","dom-change","openlist"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}