HeyPuter/puter · error · HttpError

bad_request

bad_request

Error message

`path` is required

What it means

Thrown by LegacyFSController.mkdir when the 'path' body field is absent or empty. mkdir requires a target path (optionally combined with a 'parent' for relative suffixes).

Source

Thrown at src/backend/controllers/fs/LegacyFSController.ts:612

                    ? await this.services.fs.countDirectory(parent.uuid)
                    : undefined;
            res.json({
                items: shaped,
                ...(cursor ? { cursor } : {}),
                ...(total !== undefined ? { total } : {}),
            });
            return;
        }
        res.json(shaped);
    };

    mkdir = async (req: Request, res: Response): Promise<void> => {
        const actor = this.#requireActor(req);
        const userId = this.#getActorUserId(req);
        const body = asRecord(req.body);
        const rawPath = getString(body, 'path');
        if (!rawPath)
            throw new HttpError(400, '`path` is required', {
                legacyCode: 'bad_request',
            });

        // Supports `{ parent, path }` where `path` is a relative suffix.
        // When `parent` is a path string, use it directly without requiring
        // the entry to exist — `services.fs.mkdir` honors `create_missing_parents`
        // and will materialize any missing intermediate directories.
        let targetPath = rawPath;
        if (body.parent !== undefined && !rawPath.startsWith('/')) {
            let parentPath: string;
            if (
                typeof body.parent === 'string' &&
                (body.parent.startsWith('/') || body.parent.startsWith('~'))
            ) {
                parentPath = this.#expandTilde(
                    body.parent,
                    actor.user?.username,
                );

View on GitHub (pinned to 908ec23eda)

Solutions

  1. Provide a non-empty 'path' string in the request body.
  2. Validate the path is a non-empty string before submitting.
  3. If using parent + relative path, ensure the relative suffix is still a non-empty string.

Example fix

// before
mkdir({ parent: '/docs' }); // no path

// after
mkdir({ parent: '/docs', path: 'newfolder' });
Defensive patterns

Strategy: validation

Validate before calling

if (!body.path || typeof body.path !== 'string') {
  throw new Error('mkdir requires a non-empty path');
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: POSTing to mkdir with an empty body, missing path, or path: ''.

Common situations: A form that submits before the path field is filled; a client computing the path from a variable that is undefined.

Related errors


AI-assisted analysis of HeyPuter/puter@908ec23eda (2026-08-12). Data as JSON: /api/errors/ff8b1e91c26a8bd6. Report an issue: GitHub.