{"record":{"id":"d17d54b8eb904b28","repo":"plandex-ai/plandex","slug":"name-field-is-required","errorCode":null,"errorMessage":"name field is required","messagePattern":"name field is required","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"app/server/handlers/projects.go","lineNumber":43,"sourceCode":"\t// read the request body\n\tbody, err := io.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Printf(\"Error reading request body: %v\\n\", err)\n\t\thttp.Error(w, \"Error reading request body\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\tdefer r.Body.Close()\n\n\tvar requestBody shared.CreateProjectRequest\n\tif err := json.Unmarshal(body, &requestBody); err != nil {\n\t\tlog.Printf(\"Error parsing request body: %v\\n\", err)\n\t\thttp.Error(w, \"Error parsing request body\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif requestBody.Name == \"\" {\n\t\tlog.Println(\"Received empty name field\")\n\t\thttp.Error(w, \"name field is required\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar projectId string\n\terr = db.WithTx(r.Context(), \"create project\", func(tx *sqlx.Tx) error {\n\t\tvar err error\n\n\t\tprojectId, err = db.CreateProject(auth.OrgId, requestBody.Name, tx)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error creating project: %v\\n\", err)\n\t\t\treturn fmt.Errorf(\"error creating project: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t})\n\n\tif err != nil {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/projects.go#L25-L61","documentation":"This is an input-validation error returned by the plandex server's CreateProjectHandler. The handler parses the request body into shared.CreateProjectRequest and, if the Name field is empty (missing or \"\"), it rejects the request with HTTP 400 before touching the database. It guards against creating projects with blank names.","triggerScenarios":"POST to the create-project endpoint with a JSON body where \"name\" is omitted, set to \"\", or set to null (Go decodes null into empty string). Auth must have succeeded already (Authenticate returned non-nil).","commonSituations":"CLI or client bug not setting Name before marshaling; sending {} as body; migrations or older client versions with a renamed field (e.g. sending \"projectName\" instead of \"name\"); manual curl testing with a minimal payload; string that is only whitespace is technically accepted here but empty string is not.","solutions":["Add a non-empty \"name\" field to the JSON request body and resend the request.","Check the client code path that builds shared.CreateProjectRequest to ensure Name is populated (e.g. from a --name flag or prompt).","If testing with curl, send -d '{\"name\":\"my project\"}' with Content-Type: application/json.","Trim/validate user input on the client before calling the endpoint so empty submissions are blocked locally."],"exampleFix":"// before\ncurl -X POST /projects -d '{}'\n// after\ncurl -X POST /projects -d '{\"name\":\"my project\"}'","handlingStrategy":"validation","validationCode":"name := strings.TrimSpace(req.Name)\nif name == \"\" {\n\treturn errors.New(\"name field is required\")\n}","typeGuard":"func hasName(req shared.CreateProjectRequest) bool {\n\treturn strings.TrimSpace(req.Name) != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always populate CreateProjectRequest.Name from a validated flag or prompt before sending.","Trim and check user input client-side before the HTTP call.","Keep a shared client-side validator mirroring the server's required fields.","Send requests with Content-Type: application/json and struct-marshaled bodies, never hand-built strings."],"tags":["http","validation","go","bad-request"],"backgroundTag":"missing-required-argument","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}