goharbor/harbor · error · errors.Error

BAD_REQUEST

BAD_REQUEST

Error message

bad request error level input

What it means

Error "bad request error level input" thrown in goharbor/harbor.

Source

Thrown at src/server/v2.0/handler/robot.go:170

func (rAPI *robotAPI) ListRobot(ctx context.Context, params operation.ListRobotParams) middleware.Responder {
	if err := rAPI.RequireAuthenticated(ctx); err != nil {
		return rAPI.SendError(ctx, err)
	}

	query, err := rAPI.BuildQuery(ctx, params.Q, params.Sort, params.Page, params.PageSize)
	if err != nil {
		return rAPI.SendError(ctx, err)
	}

	var projectID int64
	var level string
	// GET /api/v2.0/robots or GET /api/v2.0/robots?q=Level=system to get all of system level robots.
	// GET /api/v2.0/robots?q=Level=project,ProjectID=1
	if lv, ok := query.Keywords["Level"]; ok {
		levelStr, ok := lv.(string)
		if !ok || !isValidLevel(levelStr) {
			return rAPI.SendError(ctx, errors.New(nil).WithMessage("bad request error level input").WithCode(errors.BadRequestCode))
		}
		level = levelStr
		if level == robot.LEVELPROJECT {
			pv, ok := query.Keywords["ProjectID"]
			if !ok {
				return rAPI.SendError(ctx, errors.BadRequestError(nil).WithMessage("must with project ID when to query project robots"))
			}
			pidStr, ok := pv.(string)
			if !ok {
				return rAPI.SendError(ctx, errors.BadRequestError(nil).WithMessage("ProjectID must be a positive integer"))
			}
			pid, err := strconv.ParseInt(pidStr, 10, 64)
			if err != nil || pid <= 0 {
				return rAPI.SendError(ctx, errors.BadRequestError(nil).WithMessage("ProjectID must be a positive integer"))
			}
			projectID = pid
		} else if level == robot.LEVELSYSTEM {
			query.Keywords["ProjectID"] = 0

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/server/v2.0/handler/robot.go:170 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/86cff9cc56527df4. Report an issue: GitHub.