{"record":{"id":"0c058ce58da3e5cf","repo":"vxcontrol/pentagi","slug":"errvecstorelogsinvalidrequest","errorCode":"ErrVecstorelogsInvalidRequest","errorMessage":"group field not found","messagePattern":"group field not found","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"backend/pkg/server/services/vecstorelogs.go","lineNumber":102,"sourceCode":"\t\t}\n\t} else if slices.Contains(privs, \"vecstorelogs.view\") {\n\t\tscope = func(db *gorm.DB) *gorm.DB {\n\t\t\treturn db.\n\t\t\t\tJoins(\"INNER JOIN flows f ON f.id = flow_id\").\n\t\t\t\tWhere(\"f.user_id = ?\", uid)\n\t\t}\n\t} else {\n\t\tlogger.FromContext(c).Errorf(\"error filtering user role permissions: permission not found\")\n\t\tresponse.Error(c, response.ErrNotPermitted, nil)\n\t\treturn\n\t}\n\n\tquery.Init(\"vecstorelogs\", vecstorelogsSQLMappers)\n\n\tif query.Group != \"\" {\n\t\tif _, ok := vecstorelogsSQLMappers[query.Group]; !ok {\n\t\t\tlogger.FromContext(c).Errorf(\"error finding vecstorelogs grouped: group field not found\")\n\t\t\tresponse.Error(c, response.ErrVecstorelogsInvalidRequest, errors.New(\"group field not found\"))\n\t\t\treturn\n\t\t}\n\n\t\tvar respGrouped vecstorelogsGrouped\n\t\tif respGrouped.Total, err = query.QueryGrouped(s.db, &respGrouped.Grouped, scope); err != nil {\n\t\t\tlogger.FromContext(c).WithError(err).Errorf(\"error finding vecstorelogs grouped\")\n\t\t\tresponse.Error(c, response.ErrInternal, err)\n\t\t\treturn\n\t\t}\n\n\t\tresponse.Success(c, http.StatusOK, respGrouped)\n\t\treturn\n\t}\n\n\tif resp.Total, err = query.Query(s.db, &resp.VecstoreLogs, scope); err != nil {\n\t\tlogger.FromContext(c).WithError(err).Errorf(\"error finding vecstorelogs\")\n\t\tresponse.Error(c, response.ErrInternal, err)\n\t\treturn","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/server/services/vecstorelogs.go#L84-L120","documentation":"GetVecstorelogs checks query.Group against vecstorelogsSQLMappers before aggregating vector-store log entries; an unknown group field yields ErrVecstorelogsInvalidRequest. This whitelist keeps dynamic GROUP BY SQL safe.","triggerScenarios":"GET /vecstorelogs?group=<field> where <field> is not a key of vecstorelogsSQLMappers (typo, unmapped model field, deprecated name).","commonSituations":"Analytics dashboards sending stale group fields after a refactor, API explorers auto-suggesting model fields not registered in the mapper.","solutions":["Pick a group value present in vecstorelogsSQLMappers in backend/pkg/server/services/vecstorelogs.go","Fix the misspelled/renamed group param in the client","Register the needed field in vecstorelogsSQLMappers","Sync client-side constants with the backend mapper list"],"exampleFix":"// before\nGET /api/v1/vecstorelogs?group=proivder\n// after\nGET /api/v1/vecstorelogs?group=provider","handlingStrategy":"validation","validationCode":"const VECSTORE_GROUPS = ['type','status','created_at']; // mirror vecstorelogsSQLMappers\nif (group && !VECSTORE_GROUPS.includes(group)) throw new Error(`invalid group: ${group}`);\nawait api.get(`/vecstorelogs?group=${encodeURIComponent(group)}`);","typeGuard":"function isVecstoreGroupField(v: unknown): v is string {\n  return typeof v === 'string' && ['type','status','created_at'].includes(v);\n}","tryCatchPattern":"try {\n  return await api.getVecstorelogs({ group });\n} catch (e) {\n  if (e.response?.data?.code === 'ErrVecstorelogsInvalidRequest') {\n    return api.getVecstorelogs({}); // retry ungrouped\n  }\n  throw e;\n}","preventionTips":["Share the group-field list between backend and frontend via codegen","Validate group params in a request interceptor","Cover mapper keys with API tests","Rename fields consistently and grep for stale usages"],"tags":["api","validation","grouping"],"backgroundTag":"invalid-query-parameter","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}