{"record":{"id":"0b02a916fdfa7695","repo":"plandex-ai/plandex","slug":"error-unmarshalling-request-0b02a9","errorCode":null,"errorMessage":"Error unmarshalling request: ","messagePattern":"Error unmarshalling request: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/orgs.go","lineNumber":84,"sourceCode":"\n\tauth := Authenticate(w, r, false)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\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: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar req shared.CreateOrgRequest\n\terr = json.Unmarshal(body, &req)\n\tif err != nil {\n\t\tlog.Printf(\"Error unmarshalling request: %v\\n\", err)\n\t\thttp.Error(w, \"Error unmarshalling request: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar apiErr *shared.ApiError\n\tvar org *db.Org\n\terr = db.WithTx(r.Context(), \"create org\", func(tx *sqlx.Tx) error {\n\t\tvar err error\n\t\tvar domain *string\n\t\tif req.AutoAddDomainUsers {\n\t\t\tif shared.IsEmailServiceDomain(auth.User.Domain) {\n\t\t\t\tlog.Printf(\"Invalid domain: %v\\n\", auth.User.Domain)\n\t\t\t\treturn fmt.Errorf(\"invalid domain: %v\", auth.User.Domain)\n\t\t\t}\n\n\t\t\tdomain = &auth.User.Domain\n\t\t}\n\n\t\t// create a new org","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/orgs.go#L66-L102","documentation":"HTTP 500 error returned by CreateOrgHandler when json.Unmarshal fails to parse the request body into a shared.CreateOrgRequest. The body has already been read successfully, so this fires purely on malformed or structurally invalid JSON (wrong field types, truncated payload, or non-object input). Note the handler reports it as an internal error rather than a 400.","triggerScenarios":"Thrown at app/server/handlers/orgs.go:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log/inspect the raw body to find the JSON defect","Ensure the client sends valid CreateOrgRequest JSON with correct types","Return 400 instead of 500 for malformed client input"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}