benweet/stackedit · warning · Error

Unauthorized name.

Error message

Unauthorized name.

What it means

storeItem sanitizes an item's name before persisting it. If the item is a folder and its sanitized name matches forbiddenFolderNameMatcher (names reserved by the app), it opens an 'unauthorizedName' modal and throws 'Unauthorized name.' — the folder cannot use that reserved name.

Source

Thrown at src/services/workspaceSvc.js:83

    }

    // Return the new file item
    return store.state.file.itemsById[id];
  },

  /**
   * Make sanity checks and then create/update the folder/file in the store.
   */
  async storeItem(item) {
    const id = item.id || utils.uid();
    const sanitizedName = utils.sanitizeFilename(item.name);

    if (item.type === 'folder' && forbiddenFolderNameMatcher.exec(sanitizedName)) {
      await store.dispatch('modal/open', {
        type: 'unauthorizedName',
        item,
      });
      throw new Error('Unauthorized name.');
    }

    // Show warning dialogs
    // If name has been stripped
    if (sanitizedName !== constants.defaultName && sanitizedName !== item.name) {
      await store.dispatch('modal/open', {
        type: 'stripName',
        item,
      });
    }

    // Check if there is a path conflict
    if (store.getters['workspace/currentWorkspaceHasUniquePaths']) {
      const parentPath = store.getters.pathsByItemId[item.parentId] || '';
      const path = parentPath + sanitizedName;
      const items = store.getters.itemsByPath[path] || [];
      if (items.some(itemWithSamePath => itemWithSamePath.id !== id)) {
        await store.dispatch('modal/open', {

View on GitHub (pinned to 6dce2a5e36)

Solutions

  1. Choose a different folder name that does not match the reserved-name pattern.
  2. Sanitize the name before calling storeItem and pre-check it against forbiddenFolderNameMatcher to fail fast with your own message.
  3. If hit programmatically, catch the error and prompt the user for a new name instead of letting the throw propagate.
  4. Check constants/regex for forbiddenFolderNameMatcher to know exactly which names are disallowed.

Example fix

// before
await storeItem({ type: 'folder', name: 'data' }); // may throw 'Unauthorized name.'
// after
const sanitized = utils.sanitizeName('data');
if (constants.forbiddenFolderNameMatcher.exec(sanitized)) {
  sanitized = `${sanitized}-folder`;
}
await storeItem({ type: 'folder', name: sanitized });
Defensive patterns

Strategy: validation

Validate before calling

import constants from '@/services/constants';
const sanitizedName = utils.sanitizeName(item.name);
if (item.type === 'folder' && constants.forbiddenFolderNameMatcher.exec(sanitizedName)) {
  throw new Error(`Folder name "${sanitizedName}" is reserved`); // before calling storeItem
}

Type guard

function isAllowedFolderName(name) {
  const sanitized = utils.sanitizeName(name);
  return sanitized !== '' && !constants.forbiddenFolderNameMatcher.exec(sanitized);
}

Try / catch

try {
  await storeItem(item);
} catch (err) {
  if (err.message === 'Unauthorized name.') {
    // prompt the user for a different folder name
  } else throw err;
}

Prevention

When it happens

Trigger: Creating or renaming a folder to a name matched by forbiddenFolderNameMatcher (reserved app names) during storeItem; calling storeItem programmatically with such a name bypassing the modal-only UX flow.

Common situations: Users naming a folder like an internal route/reserved keyword; automated imports or scripts calling storeItem with unsanitized names; after a rename where trimming/case changes collide with the forbidden matcher.

Understand the failure class


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