fish2018/pansou · warning
盘链 token 为空
Error message
盘链 token 为空
What it means
resolvePanToken rejects an empty token with '盘链 token 为空' ('panlian token is empty'). A pan group entry contained no usable token/URL after trimming, so there is nothing to resolve into a real pan link.
Solutions
- Skip entries with empty tokens in resolvePanLinkTokens instead of failing the whole resolution.
- Log and drop malformed groups; verify the upstream response for that item.
- Update the PanGroup struct/parsing if upstream renamed the token field.
- Report the resource as having no links rather than surfacing an error to the user.
Example fix
// before
resolved, err := p.resolvePanToken(client, cookie, token)
if err != nil { return err }
// after
if strings.TrimSpace(token) == "" { continue } // skip empty entries
resolved, err := p.resolvePanToken(client, cookie, token) Defensive patterns
Strategy: validation
Validate before calling
// filter entries before resolution
usable := groups[:0]
for _, g := range groups {
if strings.TrimSpace(g.Token) != "" {
usable = append(usable, g)
}
} Type guard
func hasToken(g PanGroup) bool {
return strings.TrimSpace(g.Token) != ""
} Try / catch
url, err := plugin.ResolveToken(ctx, token)
if err != nil && strings.Contains(err.Error(), "盘链 token 为空") {
continue // skip empty entry, keep processing other groups
} Prevention
- Always TrimSpace token fields parsed from upstream JSON.
- Skip-and-log empty entries instead of failing the whole batch.
- Validate PanGroup JSON schema after upstream updates.
- Treat missing tokens as 'no link available', not a hard error.
When it happens
Trigger: resolvePanLinkTokens iterates groups and encounters a PanGroup item whose token field is empty or whitespace-only; upstream returned a group with missing token data.
Common situations: panlian listing includes placeholder/empty entries for items whose links were removed; JSON schema drift leaving token fields unset; scraping a deleted resource.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/7ecbd0ac0c76df8d.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/panlian/panlian.go:910
}()
}
wg.Wait()
close(resultCh)
for result := range resultCh {
group, ok := groups[result.groupKey]
if !ok || result.index < 0 || result.index >= len(group.Links) {
continue
}
group.Links[result.index].URL = result.url
groups[result.groupKey] = group
}
}
func (p *PanlianPlugin) resolvePanToken(client *http.Client, cookie string, token string) (string, error) {
token = strings.TrimSpace(token)
if token == "" {
return "", fmt.Errorf("盘链 token 为空")
}
if isRealPanURL(token) {
return token, nil
}
if client == nil {
client = p.GetClient()
}
if client == nil {
client = &http.Client{Timeout: RequestTimeout}
}
payload, err := json.Marshal(map[string]string{"token": token})
if err != nil {
return "", err
}
ctx, cancel := context.WithTimeout(context.Background(), RequestTimeout)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, DefaultBaseURL+"/api/resolve_token.php", bytes.NewReader(payload))
if err == nil {View on GitHub (pinned to beaa561337)