benweet/stackedit · error · Error

Folder ${folderId} is not accessible. Make sure you have the

Error message

Folder ${folderId} is not accessible. Make sure you have the right permissions.

What it means

When initializing a Google Drive workspace, the provider fetches the Drive folder metadata with googleHelper.getFile(token, folderId). Any failure of that call is replaced by this error at src/services/providers/googleDriveWorkspaceProvider.js:131, meaning the folder could not be read with the current token. It does not distinguish 404 (wrong ID) from 403 (no permission) or network failure.

Source

Thrown at src/services/providers/googleDriveWorkspaceProvider.js:131

        token,
        name: 'StackEdit workspace',
        parents: [],
        mediaType: googleHelper.folderMimeType,
      });
      await initFolder(token, {
        ...folder,
        appProperties: {},
      });
      folderId = folder.id;
    }

    // Init workspace
    if (!getWorkspace(folderId)) {
      let folder;
      try {
        folder = await googleHelper.getFile(token, folderId);
      } catch (err) {
        throw new Error(`Folder ${folderId} is not accessible. Make sure you have the right permissions.`);
      }
      folder.appProperties = folder.appProperties || {};
      const folderIdProperty = folder.appProperties.folderId;
      if (folderIdProperty && folderIdProperty !== folderId) {
        throw new Error(`Folder ${folderId} is part of another workspace.`);
      }
      await initFolder(token, folder);
    }

    badgeSvc.addBadge('addGoogleDriveWorkspace');
    return getWorkspace(folderId);
  },
  async performAction() {
    const state = googleHelper.driveState || {};
    const token = this.getToken();
    switch (token && state.action) {
      case 'create': {
        const driveFolder = googleHelper.driveActionFolder;

View on GitHub (pinned to 6dce2a5e36)

Solutions

  1. Confirm the folder ID and that the authenticated Google account has at least reader access to it.
  2. Reconnect the Google account so the token matches an account with access to the folder.
  3. Restore the folder from trash or create a new workspace folder.
  4. Retry if the failure was transient (network/Drive API outage); check the Drive API response in the network tab.

Example fix

// before
} catch (err) {
  throw new Error(`Folder ${folderId} is not accessible. Make sure you have the right permissions.`);
}
// after
} catch (err) {
  throw new Error(`Folder ${folderId} is not accessible. Make sure you have the right permissions. (${err && err.message})`);
}
Defensive patterns

Strategy: validation

Validate before calling

async function canAccessDriveFolder(token, folderId) {
  try {
    const res = await fetch(`https://www.googleapis.com/drive/v3/files/${encodeURIComponent(folderId)}?fields=id`,
      { headers: { Authorization: `Bearer ${token.accessToken}` } });
    return res.ok;
  } catch (e) {
    return false;
  }
}

Type guard

function isDriveFile(f) {
  return f && typeof f.id === 'string' && typeof f.name === 'string' && !f.trashed;
}

Try / catch

try {
  await provider.initWorkspace(...);
} catch (err) {
  if (/not accessible/.test(err.message)) {
    guideUserToReconnectGoogleAccountOrFixFolderId(err);
  }
}

Prevention

When it happens

Trigger: googleHelper.getFile(token, folderId) throws inside initWorkspace: folder deleted, wrong folder ID, token lacking access to that folder, Drive API error, or offline request failure.

Common situations: Pasting a folder ID the signed-in Google account cannot see; folder moved to trash; OAuth token granted for a different account; Drive API quota or transient network error during setup.

Related errors


AI-assisted analysis of benweet/stackedit@6dce2a5e36 (2026-09-01). Data as JSON: /api/errors/c503bf3ddb56fceb. Report an issue: GitHub.