vxcontrol/pentagi · error

ErrVecstorelogsInvalidRequest

ErrVecstorelogsInvalidRequest

Error message

group field not found

What it means

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.

Source

Thrown at backend/pkg/server/services/vecstorelogs.go:102

		}
	} else if slices.Contains(privs, "vecstorelogs.view") {
		scope = func(db *gorm.DB) *gorm.DB {
			return db.
				Joins("INNER JOIN flows f ON f.id = flow_id").
				Where("f.user_id = ?", uid)
		}
	} else {
		logger.FromContext(c).Errorf("error filtering user role permissions: permission not found")
		response.Error(c, response.ErrNotPermitted, nil)
		return
	}

	query.Init("vecstorelogs", vecstorelogsSQLMappers)

	if query.Group != "" {
		if _, ok := vecstorelogsSQLMappers[query.Group]; !ok {
			logger.FromContext(c).Errorf("error finding vecstorelogs grouped: group field not found")
			response.Error(c, response.ErrVecstorelogsInvalidRequest, errors.New("group field not found"))
			return
		}

		var respGrouped vecstorelogsGrouped
		if respGrouped.Total, err = query.QueryGrouped(s.db, &respGrouped.Grouped, scope); err != nil {
			logger.FromContext(c).WithError(err).Errorf("error finding vecstorelogs grouped")
			response.Error(c, response.ErrInternal, err)
			return
		}

		response.Success(c, http.StatusOK, respGrouped)
		return
	}

	if resp.Total, err = query.Query(s.db, &resp.VecstoreLogs, scope); err != nil {
		logger.FromContext(c).WithError(err).Errorf("error finding vecstorelogs")
		response.Error(c, response.ErrInternal, err)
		return

View on GitHub (pinned to ea665308ba)

Solutions

  1. Pick a group value present in vecstorelogsSQLMappers in backend/pkg/server/services/vecstorelogs.go
  2. Fix the misspelled/renamed group param in the client
  3. Register the needed field in vecstorelogsSQLMappers
  4. Sync client-side constants with the backend mapper list

Example fix

// before
GET /api/v1/vecstorelogs?group=proivder
// after
GET /api/v1/vecstorelogs?group=provider
Defensive patterns

Strategy: validation

Validate before calling

const VECSTORE_GROUPS = ['type','status','created_at']; // mirror vecstorelogsSQLMappers
if (group && !VECSTORE_GROUPS.includes(group)) throw new Error(`invalid group: ${group}`);
await api.get(`/vecstorelogs?group=${encodeURIComponent(group)}`);

Type guard

function isVecstoreGroupField(v: unknown): v is string {
  return typeof v === 'string' && ['type','status','created_at'].includes(v);
}

Try / catch

try {
  return await api.getVecstorelogs({ group });
} catch (e) {
  if (e.response?.data?.code === 'ErrVecstorelogsInvalidRequest') {
    return api.getVecstorelogs({}); // retry ungrouped
  }
  throw e;
}

Prevention

When it happens

Trigger: GET /vecstorelogs?group=<field> where <field> is not a key of vecstorelogsSQLMappers (typo, unmapped model field, deprecated name).

Common situations: Analytics dashboards sending stale group fields after a refactor, API explorers auto-suggesting model fields not registered in the mapper.

Understand the failure class

Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/0c058ce58da3e5cf. Report an issue: GitHub.