flipped-aurora/gin-vue-admin · error

dimension 仅支持 department|position|authority

Error message

dimension 仅支持 department|position|authority

What it means

The org_member_query MCP tool resolves members of a department, position, or authority (role) via a 'dimension' argument that must be one of department|position|authority. An unknown value hits the switch's default branch, which returns this error listing the three supported values. Each valid dimension maps to a different upstream endpoint and ID parameter (deptId / positionId / authorityId).

Source

Thrown at server/mcp/org_member_query.go:96

	if err != nil {
		return nil, err
	}

	withUserInfo := true
	if value, ok := args["withUserInfo"].(bool); ok {
		withUserInfo = value
	}

	var endpoint, idParam string
	switch dimension {
	case "department":
		endpoint, idParam = "/department/getDepartmentUsers", "deptId"
	case "position":
		endpoint, idParam = "/position/getPositionUsers", "positionId"
	case "authority":
		endpoint, idParam = "/authority/getUsersByAuthority", "authorityId"
	default:
		return nil, errors.New("dimension 仅支持 department|position|authority")
	}

	query := url.Values{}
	query.Set(idParam, strconv.FormatUint(uint64(targetID), 10))
	idsResp, err := getUpstream[[]uint](ctx, endpoint, query)
	if err != nil {
		return nil, fmt.Errorf("获取成员ID列表失败: %w", err)
	}
	memberIDs := idsResp.Data

	result := orgMemberResponse{
		Success:     true,
		Message:     fmt.Sprintf("共 %d 名成员", len(memberIDs)),
		Dimension:   dimension,
		TargetID:    targetID,
		MemberCount: len(memberIDs),
		MemberIDs:   memberIDs,
	}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Set dimension to exactly one of: "department", "position", or "authority" (lowercase)
  2. Replace "role" with "authority" — gin-vue-admin roles are called authorities
  3. Match the accompanying ID parameter to the dimension: deptId, positionId, or authorityId
  4. Trim/case-normalize the dimension value before calling

Example fix

// before
args := map[string]interface{}{ "dimension": "role", "authorityId": 888 }
// after
args := map[string]interface{}{ "dimension": "authority", "authorityId": 888 }
Defensive patterns

Strategy: validation

Validate before calling

var validDimensions = map[string]bool{"department": true, "position": true, "authority": true}

func validQueryArgs(args map[string]interface{}) error {
  dim, ok := args["dimension"].(string)
  if !ok || !validDimensions[dim] {
    return fmt.Errorf("dimension must be department|position|authority, got %v", args["dimension"])
  }
  return nil
}

Type guard

func isKnownDimension(v string) bool {
  return v == "department" || v == "position" || v == "authority"
}

Try / catch

res, err := callTool(ctx, "org_member_query", args)
if err != nil && strings.Contains(err.Error(), "dimension 仅支持") {
  return fmt.Errorf("unknown dimension %q: use department|position|authority", args["dimension"])
}

Prevention

When it happens

Trigger: Calling org_member_query with dimension set to anything other than department, position, or authority — e.g. 'role', 'dept', 'Department' (case-sensitive), 'user', or a translated label; dimension sent as a non-string type that fails the earlier string assertion differently.

Common situations: Callers guessing the enum from domain vocabulary ('role' instead of 'authority'); case mismatches like 'Position'; older scripts written against a different tool naming scheme; i18n clients sending localized dimension names.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/28cc7a4966704cbb. Report an issue: GitHub.