{"record":{"id":"4022bcb814319f79","repo":"toeverything/AFFiNE","slug":"unknown-workspace-role-role","errorCode":null,"errorMessage":"unknown workspace role: {role}","messagePattern":"unknown workspace role: (.+?)","errorType":"validation","errorClass":"napi::Error","httpStatus":null,"severity":"error","filePath":"packages/backend/native/src/permission/candidates.rs","lineNumber":22,"sourceCode":"\nuse super::{\n  actions::{\n    DOC_PREVIEW_ACTION, WORKSPACE_PREVIEW_ACTION, doc_actions_for_role, is_readonly_restricted_action, is_write_action,\n    workspace_actions_for_role,\n  },\n  types::{\n    Candidate, DocRole, PermissionDecisionRestrictionV1, PermissionDecisionSourceV1, PermissionDecisionV1,\n    PermissionDocInputV1, PermissionEvaluationInputV1, WorkspaceRole,\n  },\n};\n\npub(super) fn parse_workspace_role(role: &str) -> anyhow::Result<WorkspaceRole> {\n  match role {\n    \"external\" => Ok(WorkspaceRole::External),\n    \"member\" => Ok(WorkspaceRole::Member),\n    \"admin\" => Ok(WorkspaceRole::Admin),\n    \"owner\" => Ok(WorkspaceRole::Owner),\n    _ => anyhow::bail!(\"unknown workspace role: {role}\"),\n  }\n}\n\npub(super) fn parse_doc_role(role: &str) -> anyhow::Result<DocRole> {\n  match role {\n    \"none\" => Ok(DocRole::None),\n    \"external\" => Ok(DocRole::External),\n    \"reader\" => Ok(DocRole::Reader),\n    \"commenter\" => Ok(DocRole::Commenter),\n    \"editor\" => Ok(DocRole::Editor),\n    \"manager\" => Ok(DocRole::Manager),\n    \"owner\" => Ok(DocRole::Owner),\n    _ => anyhow::bail!(\"unknown doc role: {role}\"),\n  }\n}\n\npub(super) fn role_name(role: impl Serialize) -> String {\n  serde_json::to_value(role)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/591f874dad30887a80143a061a44bd3ca7ee3299/packages/backend/native/src/permission/candidates.rs#L4-L40","documentation":"An exhaustive-match fallback in parse_workspace_role: the function maps the strings 'external', 'member', 'admin', etc. to WorkspaceRole variants, and the wildcard arm fires for any other role string. It means the permission evaluation received a workspace role name from the database/request that has no corresponding WorkspaceRole variant — the interpolated value is the unrecognized role string; the faulting input is the role field of the permission input.","triggerScenarios":"Raised when permission evaluation input contains a workspace role string other than external, member, admin, or owner.","commonSituations":"A caller passed an unrecognized workspace role. Ensure the role value comes from the documented set and is serialized in lowercase.","solutions":["Map the role string to a known workspace role before evaluation.","Fix the caller to pass a valid role."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"591f874dad30887a80143a061a44bd3ca7ee3299","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}