{"record":{"id":"5a73d8606176f314","repo":"apache/answer","slug":"base-request-format-error","errorCode":"base.request_format_error","errorMessage":"base.request_format_error","messagePattern":"base\\.request_format_error","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/controller/user_plugin_controller.go","lineNumber":134,"sourceCode":"}\n\n// UpdatePluginUserConfig update user plugin config\n// @Summary update user plugin config\n// @Description update user plugin config\n// @Tags UserPlugin\n// @Accept json\n// @Produce json\n// @Security ApiKeyAuth\n// @Param data body schema.UpdateUserPluginConfigReq true \"UpdatePluginConfigReq\"\n// @Success 200 {object} handler.RespBody\n// @Router /answer/api/v1/user/plugin/config [put]\nfunc (pc *UserPluginController) UpdatePluginUserConfig(ctx *gin.Context) {\n\treq := &schema.UpdateUserPluginConfigReq{}\n\tif handler.BindAndCheck(ctx, req) {\n\t\treturn\n\t}\n\tif !plugin.StatusManager.IsEnabled(req.PluginSlugName) {\n\t\thandler.HandleResponse(ctx, errors.New(http.StatusBadRequest, reason.RequestFormatError), nil)\n\t\treturn\n\t}\n\n\treq.UserID = middleware.GetLoginUserIDFromContext(ctx)\n\n\tconfigFields, _ := json.Marshal(req.ConfigFields)\n\terr := plugin.CallUserConfig(func(fn plugin.UserConfig) error {\n\t\tif fn.Info().SlugName == req.PluginSlugName {\n\t\t\treturn fn.UserConfigReceiver(req.UserID, configFields)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\thandler.HandleResponse(ctx, err, nil)\n\t\treturn\n\t}\n\n\terr = pc.pluginCommonService.UpdatePluginUserConfig(ctx, req)","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/controller/user_plugin_controller.go#L116-L152","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"pluginSlugName\":\"reviewer\",\"configFields\":\"{}\"}\n// after\n{\"plugin_slug_name\":\"reviewer\",\"config_fields\":{\"enabled\":true}}","handlingStrategy":"validation","validationCode":"const body = { plugin_slug_name: 'reviewer', config_fields: { enabled: true } };\nif (typeof body.plugin_slug_name !== 'string' || typeof body.config_fields !== 'object') {\n  throw new TypeError('UpdateUserPluginConfig payload malformed');\n}","typeGuard":"function isValidConfigReq(b: unknown): b is { plugin_slug_name: string; config_fields: Record<string, unknown> } {\n  const r = b as any;\n  return typeof r?.plugin_slug_name === 'string' && r.config_fields !== null && typeof r.config_fields === 'object';\n}","tryCatchPattern":"try {\n  await api.updatePluginUserConfig(payload);\n} catch (e) {\n  if (e?.code === 'base.request_format_error') {\n    console.error('Payload/schema mismatch or plugin not enabled', payload);\n  }\n}","preventionTips":["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"],"tags":["api","validation","plugin","go"],"backgroundTag":"request-format-error","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}