{"record":{"id":"27bd4d6bce101b9f","repo":"plandex-ai/plandex","slug":"model-pack-name-is-required","errorCode":null,"errorMessage":"Model pack name is required","messagePattern":"Model pack name is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"app/server/handlers/models.go","lineNumber":96,"sourceCode":"\t\t\tmsg := \"Model id is required\"\n\t\t\tlog.Println(msg)\n\t\t\thttp.Error(w, msg, http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tif shared.BuiltInBaseModelsById[model.ModelId] != nil {\n\t\t\tmsg := fmt.Sprintf(\"%s is a built-in base model id, so it can't be used for a custom model\", model.ModelId)\n\t\t\tlog.Println(msg)\n\t\t\thttp.Error(w, msg, http.StatusUnprocessableEntity)\n\t\t\treturn\n\t\t}\n\t}\n\n\tfor _, modelPack := range modelsInput.CustomModelPacks {\n\t\tif modelPack.Name == \"\" {\n\t\t\tmsg := \"Model pack name is required\"\n\t\t\tlog.Println(msg)\n\t\t\thttp.Error(w, msg, http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\tif shared.BuiltInModelPacksByName[modelPack.Name] != nil {\n\t\t\tmsg := fmt.Sprintf(\"%s is a built-in model pack name, so it can't be used for a custom model pack\", modelPack.Name)\n\t\t\tlog.Println(msg)\n\t\t\thttp.Error(w, msg, http.StatusUnprocessableEntity)\n\t\t\treturn\n\t\t}\n\t}\n\n\tvar existingCustomModelIds = make(map[shared.ModelId]bool)\n\tvar existingCustomProviderNames = make(map[string]bool)\n\n\tcustomModels, err := db.ListCustomModels(auth.OrgId)\n\tif err != nil {\n\t\tlog.Printf(\"Error fetching custom models: %v\\n\", err)\n\t\thttp.Error(w, \"Failed to create custom model: \"+err.Error(), http.StatusInternalServerError)","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/models.go#L78-L114","documentation":"Every custom model pack in the ModelsInput must have a non-empty Name, which identifies the pack in role configuration. If any entry in CustomModelPacks has an empty Name, the handler rejects the request with HTTP 400 and this message.","triggerScenarios":"POSTing to the custom models upsert endpoint with a CustomModelPacks element whose name field is missing or empty.","commonSituations":"Hand-writing a model pack in models.json and omitting the name key; scripted pack generation where a name variable was empty; stripping the name during a JSON transformation.","solutions":["Set a unique, non-empty name on every object in the customModelPacks array","Validate pack names client-side before sending the request","Inspect the outgoing JSON for packs with name: \"\" or a missing name key","Choose names distinct from built-in model pack names (that raises a separate 422 error)"],"exampleFix":"// before\n{\"customModelPacks\": [{\"models\": {\"plan\": \"my-model\"}}]}\n// after\n{\"customModelPacks\": [{\"name\": \"my-pack\", \"models\": {\"plan\": \"my-model\"}}]}","handlingStrategy":"validation","validationCode":"for i, p := range input.CustomModelPacks {\n    if p.Name == \"\" {\n        return fmt.Errorf(\"customModelPacks[%d].name is required\", i)\n    }\n}","typeGuard":"func packNamed(p *shared.ModelPackSchema) bool { return p != nil && p.Name != \"\" }","tryCatchPattern":null,"preventionTips":["Validate every model pack has a non-empty name before submitting","Also check names against built-in model pack names","Make name a required key in pack templates and generators"],"tags":["http","go","validation","missing-field","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-14T00:17:10.932Z"}