flipped-aurora/gin-vue-admin · error
解析 params 参数失败: %v
Error message
解析 params 参数失败: %v
What it means
ExportExcel parses the 'params' query value as a URL query string (url.ParseQuery). If the params value is empty or not valid form-encoded data (e.g. missing '=' separators, bad percent-encoding), it returns this wrapped error.
Source
Thrown at server/service/system/sys_export_template.go:135
if err != nil {
return
}
if limit != 0 {
db = db.Limit(limit).Offset(offset)
}
err = db.Find(&sysExportTemplates).Error
return sysExportTemplates, total, err
}
// ExportExcel 导出Excel
// Author [piexlmax](https://github.com/piexlmax)
func (sysExportTemplateService *SysExportTemplateService) ExportExcel(ctx context.Context, templateID string, values url.Values) (file *bytes.Buffer, name string, err error) {
var params = values.Get("params")
paramsValues, err := url.ParseQuery(params)
if err != nil {
return nil, "", fmt.Errorf("解析 params 参数失败: %v", err)
}
var template system.SysExportTemplate
err = global.GVA_DB.WithContext(ctx).Preload("Conditions").Preload("JoinTemplate").First(&template, "template_id = ?", templateID).Error
if err != nil {
return nil, "", err
}
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
// Create a new sheet.
index, err := f.NewSheet("Sheet1")
if err != nil {
fmt.Println(err)
return
}View on GitHub (pinned to 3136500ef3)
Solutions
- Encode params correctly, e.g. params=encodeURIComponent(' conditions=a&dictType=b ')
- Ensure every pair has form key=value separated by &
- Check the request actually reaches the service with params intact (not stripped by middleware)
- Log the raw params value at the handler layer to confirm what is received
Example fix
// before
const qs = `conditions=${conditions}&dictType=${dictType}` // unencoded, may break
// after
const qs = new URLSearchParams({ conditions, dictType }).toString()
await exportExcel(templateId, `params=${encodeURIComponent(qs)}`) Defensive patterns
Strategy: validation
Validate before calling
const inner = new URLSearchParams(payload).toString()
const params = new URLSearchParams({ params: inner }).toString()
// params guaranteed valid form-encoding Try / catch
try {
await exportExcel(templateId, params)
} catch (e) {
if (e.message.includes('解析 params')) {
ElMessage.error('导出参数格式错误')
}
} Prevention
- Centralize export param building in one util
- Round-trip test params: parse what you build
When it happens
Trigger: GET/POST export with params=<malformed> such as params=conditions (no key=value pair) or params=a%zz=1 (invalid percent-encoding); params omitted entirely yields empty string which ParseQuery accepts, so it fails only on truly invalid syntax.
Common situations: Frontend building params manually without encodeURIComponent; proxies or log sanitizers stripping or mangling query encoding; copy-pasted URLs with truncated params.
Related errors
- order by %s is not in the fields
- order by %s is not secure
- 当前响应不支持流式输出
- 当前响应不支持流式输出
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/28df77a4590e9eb3.
Report an issue: GitHub.