{"record":{"id":"d85402bff118bf7a","repo":"laurent22/joplin","slug":"no-share-found-for-folder-folderid","errorCode":null,"errorMessage":"No share found for folder ${folderId}","messagePattern":"No share found for folder (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-share.ts","lineNumber":45,"sourceCode":"};\n\n\nconst folderTitle = (folder: FolderEntity|null) => {\n\treturn folder ? substrWithEllipsis(folder.title, 0, 32) : _('[None]');\n};\n\nconst getShareState = () => app().store().getState().shareService;\nconst getShareFromFolderId = (folderId: string) => {\n\tconst shareState = getShareState();\n\tconst allShares = shareState.shares;\n\tconst share = allShares.find(share => share.folder_id === folderId);\n\treturn share;\n};\n\nconst getShareUsers = (folderId: string) => {\n\tconst share = getShareFromFolderId(folderId);\n\tif (!share) {\n\t\tthrow new Error(`No share found for folder ${folderId}`);\n\t}\n\treturn getShareState().shareUsers[share.id];\n};\n\n\nclass Command extends BaseCommand {\n\tpublic usage() {\n\t\treturn 'share <command> [notebook] [user]';\n\t}\n\n\tpublic description() {\n\t\treturn [\n\t\t\t_('Shares or unshares the specified [notebook] with [user]. Requires Joplin Cloud or Joplin Server.'),\n\t\t\t_('Commands: `add`, `remove`, `list`, `delete`, `accept`, `leave`, and `reject`.'),\n\t\t].join('\\n');\n\t}\n\n\tpublic options() {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-share.ts#L27-L63","documentation":"Thrown by the helper `getShareUsers` in command-share.ts when no share object in the redux `shareService.shares` array has a `folder_id` equal to the given folderId. The helper is used while listing or modifying recipients, so a missing share means the folder is not currently shared from this client's viewpoint. The folderId is interpolated into the message for diagnostics.","triggerScenarios":"Calling `share remove <notebook> <user>` or `share list <notebook>` on a folder whose share has not been loaded into redux state, was never shared, or was unshared in another client and not yet synced. Also after `refreshShares()` returns an empty/changed list because the share was revoked server-side.","commonSituations":"Running `share remove` before `share add`; race where the share was deleted by another collaborator; Joplin Cloud/Server account state is stale because sync has not run; testing against a non-sharing sync target (e.g. local filesystem) where shares never populate.","solutions":["Run `:sync` to refresh share state from the server, then retry.","Confirm the folder is actually shared with `share list <notebook>` first.","If the share was removed elsewhere, no action is needed — the error is correct.","Verify you are logged into a Joplin Cloud or Joplin Server account that supports sharing."],"exampleFix":"// before\nconst getShareUsers = (folderId: string) => {\n\tconst share = getShareFromFolderId(folderId);\n\tif (!share) throw new Error(`No share found for folder ${folderId}`);\n\treturn getShareState().shareUsers[share.id];\n};\n\n// after - return undefined and let callers decide, avoiding the misleading 'share missing' when only users are absent\nconst getShareUsers = (folderId: string) => {\n\tconst share = getShareFromFolderId(folderId);\n\tif (!share) return undefined;\n\treturn getShareState().shareUsers[share.id];\n};","handlingStrategy":"validation","validationCode":"const share = getShareFromFolderId(folderId);\nif (!share) {\n\tthrow new Error(`Folder ${folderId} is not shared (or share state is stale). Run \\`:sync\\` and \\`share list\\`.`);\n}","typeGuard":"const isShared = (folderId: string, shares: ShareEntity[]): boolean => shares.some(s => s.folder_id === folderId);","tryCatchPattern":"try {\n\tawait ShareService.instance().refreshShares();\n\tconst users = getShareUsers(folderId);\n} catch (e) {\n\tif (/No share found/.test(e.message)) { /* sync then retry, or surface to user */ }\n\telse throw e;\n}","preventionTips":["Call `ShareService.instance().refreshShares()` before reading share state.","Sync before any share mutation so redux state is current.","Distinguish 'not shared' from 'no recipients' in your own error messages."],"tags":["share","notebook","share-users","cli","not-found","joplin-cloud"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}