Mintplex-Labs/anything-llm · error

Failed to create folder

Error message

Failed to create folder: ${e.message}

What it means

Catch-all in the create-folder API: filesystem operations (mkdirSync or path validation) threw unexpectedly, and the underlying exception's message is wrapped in a 500 response describing the folder-creation failure.

Solutions

  1. Read the embedded error message for the underlying cause (permissions, name conflict, storage error).
  2. Verify the storage directory is writable and retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at server/endpoints/api/document/index.js:955 when the library encounters an invalid state.

Common situations: Folder creation failed due to a filesystem or database error surfaced in e.message.


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/781fbc05c4d1e5fd. Report an issue: GitHub.

Appendix: source

Thrown at server/endpoints/api/document/index.js:955

      try {
        const { name } = reqBody(request);
        const storagePath = path.join(documentsPath, normalizePath(name));
        if (!isWithin(path.resolve(documentsPath), path.resolve(storagePath)))
          throw new Error("Invalid path name");

        if (fs.existsSync(storagePath)) {
          response.status(500).json({
            success: false,
            message: "Folder by that name already exists",
          });
          return;
        }

        fs.mkdirSync(storagePath, { recursive: true });
        response.status(200).json({ success: true, message: null });
      } catch (e) {
        console.error(e);
        response.status(500).json({
          success: false,
          message: `Failed to create folder: ${e.message}`,
        });
      }
    }
  );

  app.delete(
    "/v1/document/remove-folder",
    [validApiKey],
    async (request, response) => {
      /*
      #swagger.tags = ['Documents']
      #swagger.description = 'Remove a folder and all its contents from the documents storage directory.'
      #swagger.requestBody = {
        description: 'Name of the folder to remove.',
        required: true,
        content: {

View on GitHub (pinned to 3aec848f28)