jeessy2/ddns-go · error
dnsla 记录列表请求失败,状态码: %d, 响应: %s
Error message
dnsla 记录列表请求失败,状态码: %d, 响应: %s
What it means
This error is returned when the dnsla record-list API responds with a non-200 HTTP status code. The message includes the status code and the raw response body, which typically contains dnsla's JSON error describing why the request was rejected (auth failure, invalid domain, rate limiting, etc.). The request itself succeeded at the transport level but the API rejected it.
Source
Thrown at dns/dnsla.go:282
token := "Basic " + base64.StdEncoding.EncodeToString(byteBuff)
// 设置 Headers
req.Header.Set("Authorization", token)
// 发送请求
client := dnsla.httpClient
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("请求 dnsla 记录列表失败: %w", err)
}
defer resp.Body.Close()
// 读取响应
result, err = io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("读取 dnsla 记录列表响应失败: %w", err)
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("dnsla 记录列表请求失败,状态码: %d, 响应: %s", resp.StatusCode, string(result))
}
return result, nil
}
View on GitHub (pinned to 5874c2e666)
Solutions
- Read the response body in the error message — dnsla's JSON explains the rejection reason
- For 401/403, verify the DNS ID and Secret configured for the dnsla provider are correct and active
- For 429, reduce request concurrency or add retry with exponential backoff
- For 404, confirm the endpoint URL matches the current dnsla API version
- For 5xx, retry later; check dnsla service status
Example fix
// before
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("dnsla 记录列表请求失败,状态码: %d, 响应: %s", resp.StatusCode, string(result))
}
// after
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusUnauthorized {
return nil, fmt.Errorf("dnsla 认证失败 (401),请检查 DNS ID 和 Secret: %s", string(result))
}
return nil, fmt.Errorf("dnsla 记录列表请求失败,状态码: %d, 响应: %s", resp.StatusCode, string(result))
} Defensive patterns
Strategy: try-catch
Validate before calling
// 发送前校验 dnsla 凭据非空
if dnsla.DNS.ID == "" || dnsla.DNS.Secret == "" {
return fmt.Errorf("dnsla DNS ID 或 Secret 未配置")
} Type guard
type APIStatusError struct {
StatusCode int
Body string
}
func asStatusError(err error) (*APIStatusError, bool) {
var se *APIStatusError
if errors.As(err, &se) {
return se, true
}
return nil, false
} Try / catch
records, err := getRecordList(...)
if err != nil {
if strings.Contains(err.Error(), "状态码: 401") || strings.Contains(err.Error(), "状态码: 403") {
return fmt.Errorf("dnsla 认证失败,请检查 DNS ID/Secret: %w", err)
}
if strings.Contains(err.Error(), "状态码: 429") {
return retryWithBackoff()
}
return err
} Prevention
- Double-check the dnsla API ID and Secret before running bulk updates
- Keep pageSize requests modest and space out bulk operations to avoid 429
- Log the response body on non-200 to capture dnsla's own error message
- Monitor for dnsla API version/endpoint changes
When it happens
Trigger: resp.StatusCode != http.StatusOK: 401/403 from invalid or expired API ID/Secret (Basic auth token), 404 from wrong endpoint, 429 rate limiting, 5xx server errors, or 400 from a malformed domain name parameter.
Common situations: Wrong dnsla API ID or Secret (token is built as base64(ID:Secret) — a typo yields 401); the domain being managed doesn't exist in the dnsla account; API key revoked or account expired; hitting rate limits during bulk record updates across many domains.
Related errors
- API请求失败,状态码: %d, 响应: %s
- API请求失败,状态码: %d, 响应: %s
- dnsla 请求失败,状态码: %d, 响应: %s
- 创建 dnsla 记录列表请求失败: %w
- 请求 dnsla 记录列表失败: %w
AI-assisted analysis of jeessy2/ddns-go@5874c2e666 (2026-09-03).
Data as JSON: /api/errors/983bb71ba08fe10d.
Report an issue: GitHub.