{"record":{"id":"ff8b1e91c26a8bd6","repo":"HeyPuter/puter","slug":"bad-request-ff8b1e","errorCode":"bad_request","errorMessage":"`path` is required","messagePattern":"`path` is required","errorType":"http","errorClass":"HttpError","httpStatus":400,"severity":"error","filePath":"src/backend/controllers/fs/LegacyFSController.ts","lineNumber":612,"sourceCode":"                    ? await this.services.fs.countDirectory(parent.uuid)\n                    : undefined;\n            res.json({\n                items: shaped,\n                ...(cursor ? { cursor } : {}),\n                ...(total !== undefined ? { total } : {}),\n            });\n            return;\n        }\n        res.json(shaped);\n    };\n\n    mkdir = async (req: Request, res: Response): Promise<void> => {\n        const actor = this.#requireActor(req);\n        const userId = this.#getActorUserId(req);\n        const body = asRecord(req.body);\n        const rawPath = getString(body, 'path');\n        if (!rawPath)\n            throw new HttpError(400, '`path` is required', {\n                legacyCode: 'bad_request',\n            });\n\n        // Supports `{ parent, path }` where `path` is a relative suffix.\n        // When `parent` is a path string, use it directly without requiring\n        // the entry to exist — `services.fs.mkdir` honors `create_missing_parents`\n        // and will materialize any missing intermediate directories.\n        let targetPath = rawPath;\n        if (body.parent !== undefined && !rawPath.startsWith('/')) {\n            let parentPath: string;\n            if (\n                typeof body.parent === 'string' &&\n                (body.parent.startsWith('/') || body.parent.startsWith('~'))\n            ) {\n                parentPath = this.#expandTilde(\n                    body.parent,\n                    actor.user?.username,\n                );","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/controllers/fs/LegacyFSController.ts#L594-L630","documentation":"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).","triggerScenarios":"POSTing to mkdir with an empty body, missing path, or path: ''.","commonSituations":"A form that submits before the path field is filled; a client computing the path from a variable that is undefined.","solutions":["Provide a non-empty 'path' string in the request body.","Validate the path is a non-empty string before submitting.","If using parent + relative path, ensure the relative suffix is still a non-empty string."],"exampleFix":"// before\nmkdir({ parent: '/docs' }); // no path\n\n// after\nmkdir({ parent: '/docs', path: 'newfolder' });","handlingStrategy":"validation","validationCode":"if (!body.path || typeof body.path !== 'string') {\n  throw new Error('mkdir requires a non-empty path');\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Build the full path (parent + name) before submit.","Disable submit until a path is present.","Use the parent + relative suffix form if you only have a folder name."],"tags":["fs","legacy","mkdir","validation"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}