{"record":{"id":"cf738cdfd3c0a667","repo":"benweet/stackedit","slug":"folder-folderid-is-part-of-another-workspace","errorCode":null,"errorMessage":"Folder ${folderId} is part of another workspace.","messagePattern":"Folder (.+?) is part of another workspace\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/providers/googleDriveWorkspaceProvider.js","lineNumber":136,"sourceCode":"      await initFolder(token, {\n        ...folder,\n        appProperties: {},\n      });\n      folderId = folder.id;\n    }\n\n    // Init workspace\n    if (!getWorkspace(folderId)) {\n      let folder;\n      try {\n        folder = await googleHelper.getFile(token, folderId);\n      } catch (err) {\n        throw new Error(`Folder ${folderId} is not accessible. Make sure you have the right permissions.`);\n      }\n      folder.appProperties = folder.appProperties || {};\n      const folderIdProperty = folder.appProperties.folderId;\n      if (folderIdProperty && folderIdProperty !== folderId) {\n        throw new Error(`Folder ${folderId} is part of another workspace.`);\n      }\n      await initFolder(token, folder);\n    }\n\n    badgeSvc.addBadge('addGoogleDriveWorkspace');\n    return getWorkspace(folderId);\n  },\n  async performAction() {\n    const state = googleHelper.driveState || {};\n    const token = this.getToken();\n    switch (token && state.action) {\n      case 'create': {\n        const driveFolder = googleHelper.driveActionFolder;\n        let syncData = store.getters['data/syncDataById'][driveFolder.id];\n        if (!syncData && driveFolder.appProperties.id) {\n          // Create folder if not already synced\n          store.commit('folder/setItem', {\n            id: driveFolder.appProperties.id,","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/benweet/stackedit/blob/6dce2a5e36b755a0c244522b48a06c91a2df0f59/src/services/providers/googleDriveWorkspaceProvider.js#L118-L154","documentation":"Google Drive folders can be claimed by at most one workspace; the provider stamps the folder's appProperties.folderId with the workspace's folder ID. If the fetched folder already has a folderId property that differs from the folderId being initialized, initWorkspace throws this error at src/services/providers/googleDriveWorkspaceProvider.js:136. It is a deliberate conflict guard preventing two workspaces from sharing one Drive folder.","triggerScenarios":"Calling initWorkspace on a Drive folder whose appProperties.folderId exists and does not equal the requested folderId — i.e. the folder was already initialized as (or renamed/reused from) another workspace.","commonSituations":"Reusing a folder that previously belonged to a deleted workspace; pointing a new workspace at an old workspace's folder; syncing/copying a workspace folder so its appProperties carried over.","solutions":["Pick a fresh, empty Drive folder for the new workspace.","Clear the appProperties.folderId property on the existing folder (via Drive API or the original workspace) before reusing it.","Open the workspace that already owns this folder instead of creating a new one.","Verify you did not paste the wrong folder ID when configuring the workspace."],"exampleFix":"// before\nthrow new Error(`Folder ${folderId} is part of another workspace.`);\n// after\nconst reuse = confirm(`Folder ${folderId} belongs to another workspace. Reinitialize it for this workspace?`);\nif (!reuse) {\n  throw new Error(`Folder ${folderId} is part of another workspace.`);\n}\nfolder.appProperties.folderId = folderId;","handlingStrategy":"validation","validationCode":"async function folderBelongsToWorkspace(token, folderId) {\n  const meta = await fetch(`https://www.googleapis.com/drive/v3/files/${encodeURIComponent(folderId)}?fields=appProperties`,\n    { headers: { Authorization: `Bearer ${token.accessToken}` } }).then(r => r.json());\n  const claimed = meta.appProperties && meta.appProperties.folderId;\n  return !claimed || claimed === folderId ? null : claimed;\n}","typeGuard":"function isClaimedByOtherWorkspace(folder, folderId) {\n  const claimed = folder && folder.appProperties && folder.appProperties.folderId;\n  return typeof claimed === 'string' && claimed !== '' && claimed !== folderId;\n}","tryCatchPattern":"try {\n  await provider.initWorkspace(...);\n} catch (err) {\n  if (/part of another workspace/.test(err.message)) {\n    promptUserToChooseAFreshFolderOrOpenExistingWorkspace(err);\n  }\n}","preventionTips":["Always create workspaces in fresh, empty Drive folders.","Never copy/duplicate an existing workspace folder — its appProperties travel with it.","Check folder appProperties before pointing a new workspace at a folder.","Open the existing workspace instead of re-initializing its folder."],"tags":["google-drive","workspace","conflict"],"backgroundTag":"workspace-folder-conflict","analyzedSha":"6dce2a5e36b755a0c244522b48a06c91a2df0f59","analyzedAt":"2026-09-01T00:49:23.866Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}