{"record":{"id":"6c3e68d5a92590d1","repo":"Tencent/WeKnora","slug":"invite-code-validity-days-must-be-0-1-7-or-30","errorCode":null,"errorMessage":"invite_code_validity_days must be 0, 1, 7, or 30","messagePattern":"invite_code_validity_days must be 0, 1, 7, or 30","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/organization.go","lineNumber":35,"sourceCode":"\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}\n\n// NewOrganizationService creates a new organization service","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/organization.go#L17-L53","documentation":"Sentinel ErrInvalidValidityDays returned by org create/update when req.InviteCodeValidityDays is set to a value outside the allowed set {0,1,7,30} (checked against ValidInviteCodeValidityDays). Pure input validation of the settings field.","triggerScenarios":"Thrown at internal/application/service/organization.go:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send 0 (never), 1, 7, or 30 days for invite_code_validity_days","Fix client-side validation to restrict the field to allowed values"],"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"}