{"record":{"id":"3b0f38d929a99f8b","repo":"Tencent/WeKnora","slug":"invalid-role","errorCode":null,"errorMessage":"invalid role","messagePattern":"invalid role","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/organization.go","lineNumber":33,"sourceCode":"\t\"github.com/google/uuid\"\n)\n\n// Default invite code validity in days; allowed values: 0 (never), 1, 7, 30\nconst DefaultInviteCodeValidityDays = 7\n\n// DefaultMemberLimit is the default max tenant-members per organization (0 = unlimited)\nconst DefaultMemberLimit = 200\n\n// ValidInviteCodeValidityDays are the allowed values for invite_code_validity_days\nvar ValidInviteCodeValidityDays = map[int]bool{0: true, 1: true, 7: true, 30: true}\n\nvar (\n\tErrOrgNotFound           = errors.New(\"organization not found\")\n\tErrOrgPermissionDenied   = errors.New(\"permission denied for this organization\")\n\tErrCannotRemoveOwner     = errors.New(\"cannot remove organization owner tenant\")\n\tErrCannotChangeOwnerRole = errors.New(\"cannot change organization owner tenant role\")\n\tErrTenantNotInOrg        = errors.New(\"tenant is not a member of this organization\")\n\tErrInvalidRole           = errors.New(\"invalid role\")\n\tErrInviteCodeExpired     = errors.New(\"invite code has expired\")\n\tErrInvalidValidityDays   = errors.New(\"invite_code_validity_days must be 0, 1, 7, or 30\")\n\tErrOrgMemberLimitReached = errors.New(\"organization member limit reached\")\n\tErrOrgMemberLimitTooLow  = errors.New(\"member limit cannot be lower than current member count\")\n)\n\n// organizationService implements OrganizationService.\n//\n// Plan 3 of #1303: a \"member\" of an org is a tenant, identified by\n// (org_id, tenant_id). The user_id of the requester is recorded only as\n// the representative for UI/audit; permission decisions ride on the\n// tenant's role inside the org.\ntype organizationService struct {\n\torgRepo        interfaces.OrganizationRepository\n\tuserRepo       interfaces.UserRepository\n\tshareRepo      interfaces.KBShareRepository\n\tagentShareRepo interfaces.AgentShareRepository\n}","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/organization.go#L15-L51","documentation":"Sentinel ErrInvalidRole returned by share/KB permission flows when the requested permission level fails permission.IsValid() — the role string is not one of the recognized levels (e.g. read/write/admin). Input-validation guard on the permission argument.","triggerScenarios":"Thrown at internal/application/service/organization.go:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send one of the valid permission levels supported by the API","Fix the role enum/casing in the client or migration data"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}