AlistGo/alist · error

not find %s function

Error message

not find %s function

What it means

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.

Source

Thrown at drivers/lanzou/help.go:240

	block := make([]string, len(indexs))
	for i, next := len(indexs)-1, len(html); i >= 0; i-- {
		index := indexs[i]
		block[i] = html[index[1]:next]
		next = index[0]
	}
	return strings.Join(block, "")
}

// 根据名称获取方法
func getJSFunctionByName(html string, name string) (string, error) {
	indexs := findJSFunctionIndex(html, true)
	for _, index := range indexs {
		data := html[index[0]:index[1]]
		if regexp.MustCompile(`function\s+` + name + `[()\s]+{`).MatchString(data) {
			return data, nil
		}
	}
	return "", fmt.Errorf("not find %s function", name)
}

// 解析html中的JSON,选择最长的数据
func htmlJsonToMap2(html string) (map[string]string, error) {
	datas := findDataReg.FindAllStringSubmatch(html, -1)
	var sData string
	for _, data := range datas {
		if len(datas) > 0 && len(data[1]) > len(sData) {
			sData = data[1]
		}
	}
	if sData == "" {
		return nil, fmt.Errorf("not find data")
	}
	return jsonToMap(sData, html), nil
}

// 解析html中的JSON

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Update OpenList to the latest release — lanzou page parsing is fixed repeatedly as LanZou changes
  2. 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)
  3. Report the page HTML (debug log) upstream so the function-name regex is updated
Defensive patterns

Strategy: fallback

Type guard

func hasJSFunction(html, name string) bool {
    for _, idx := range findJSFunctionIndex(html, true) {
        if regexp.MustCompile(`function\s+` + name + `[()\s]+{`).MatchString(html[idx[0]:idx[1]]) {
            return true
        }
    }
    return false
}

Try / catch

fn, err := getJSFunctionByName(html, name)
if err != nil {
    // page variant changed; retry after delay or fail with the page snippet for diagnosis
    return fmt.Errorf("lanzou page missing function %q (frontend change?): %w", name, err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/2b2028a9cb535524. Report an issue: GitHub.