apache/answer · error
base.request_format_error
base.request_format_error
Error message
base.request_format_error
What it means
UpdatePluginUserConfig returns base.request_format_error when the request body fails binding/validation (handler.BindAndCheck returns true) — the JSON payload does not match schema.UpdateUserPluginConfigReq. In this handler it is also returned when the target plugin is not enabled, both surfaces produce the same error code.
Solutions
- Log/inspect the request body and compare it against schema.UpdateUserPluginConfigReq; fix field names and types.
- Ensure Content-Type: application/json and that config_fields is a valid JSON object of plugin config fields.
- Verify the plugin is enabled via plugin.StatusManager (check the plugin slug name matches an installed, enabled plugin).
- Re-login if the request is missing auth context.
Example fix
// before
{"pluginSlugName":"reviewer","configFields":"{}"}
// after
{"plugin_slug_name":"reviewer","config_fields":{"enabled":true}} Defensive patterns
Strategy: validation
Validate before calling
const body = { plugin_slug_name: 'reviewer', config_fields: { enabled: true } };
if (typeof body.plugin_slug_name !== 'string' || typeof body.config_fields !== 'object') {
throw new TypeError('UpdateUserPluginConfig payload malformed');
} Type guard
function isValidConfigReq(b: unknown): b is { plugin_slug_name: string; config_fields: Record<string, unknown> } {
const r = b as any;
return typeof r?.plugin_slug_name === 'string' && r.config_fields !== null && typeof r.config_fields === 'object';
} Try / catch
try {
await api.updatePluginUserConfig(payload);
} catch (e) {
if (e?.code === 'base.request_format_error') {
console.error('Payload/schema mismatch or plugin not enabled', payload);
}
} Prevention
- Mirror the Go schema field names (snake_case) exactly in the client
- Check plugin enabled status before calling config endpoints
- Send Content-Type: application/json
- Validate payloads with a shared schema (JSON Schema / zod) in dev
When it happens
Trigger: PUT/POST to the plugin user-config endpoint with malformed JSON, missing required fields (e.g. plugin_slug_name or config_fields wrong shape), wrong content-type, or requesting a plugin whose slug is not in the enabled state.
Common situations: Frontend sending config_fields as a non-object, typo in plugin_slug_name, plugin disabled/uninstalled but still referenced by a stale dashboard, or session/auth context missing so user id resolution differs from expectations.
Related errors
- decode image config error
- error.password.space_invalid
- image size too large
- the password does not satisfy the current policy…
- validate check exception
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/5a73d8606176f314.
Report an issue: GitHub.
Appendix: source
Thrown at internal/controller/user_plugin_controller.go:134
}
// UpdatePluginUserConfig update user plugin config
// @Summary update user plugin config
// @Description update user plugin config
// @Tags UserPlugin
// @Accept json
// @Produce json
// @Security ApiKeyAuth
// @Param data body schema.UpdateUserPluginConfigReq true "UpdatePluginConfigReq"
// @Success 200 {object} handler.RespBody
// @Router /answer/api/v1/user/plugin/config [put]
func (pc *UserPluginController) UpdatePluginUserConfig(ctx *gin.Context) {
req := &schema.UpdateUserPluginConfigReq{}
if handler.BindAndCheck(ctx, req) {
return
}
if !plugin.StatusManager.IsEnabled(req.PluginSlugName) {
handler.HandleResponse(ctx, errors.New(http.StatusBadRequest, reason.RequestFormatError), nil)
return
}
req.UserID = middleware.GetLoginUserIDFromContext(ctx)
configFields, _ := json.Marshal(req.ConfigFields)
err := plugin.CallUserConfig(func(fn plugin.UserConfig) error {
if fn.Info().SlugName == req.PluginSlugName {
return fn.UserConfigReceiver(req.UserID, configFields)
}
return nil
})
if err != nil {
handler.HandleResponse(ctx, err, nil)
return
}
err = pc.pluginCommonService.UpdatePluginUserConfig(ctx, req)View on GitHub (pinned to 3b9f137061)