{"record":{"id":"beb239e4b6f918b3","repo":"netbirdio/netbird","slug":"posture-checks-name-shouldn-t-be-empty","errorCode":null,"errorMessage":"posture checks name shouldn't be empty","messagePattern":"posture checks name shouldn't be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"management/server/posture/checks.go","lineNumber":301,"sourceCode":"\t\tchecks.PeerNetworkRangeCheck = toPeerNetworkRangeCheckResponse(pc.Checks.PeerNetworkRangeCheck)\n\t}\n\n\tif pc.Checks.ProcessCheck != nil {\n\t\tchecks.ProcessCheck = toProcessCheckResponse(pc.Checks.ProcessCheck)\n\t}\n\n\treturn &api.PostureCheck{\n\t\tId:          pc.ID,\n\t\tName:        pc.Name,\n\t\tDescription: &pc.Description,\n\t\tChecks:      checks,\n\t}\n}\n\n// Validate checks the validity of a posture checks.\nfunc (pc *Checks) Validate() error {\n\tif pc.Name == \"\" {\n\t\treturn errors.New(\"posture checks name shouldn't be empty\")\n\t}\n\n\tchecks := pc.GetChecks()\n\tif len(checks) == 0 {\n\t\treturn errors.New(\"posture checks shouldn't be empty\")\n\t}\n\n\tfor _, check := range checks {\n\t\tif err := check.Validate(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc isVersionValid(ver string) bool {\n\tnewVersion, err := version.NewVersion(ver)","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/netbirdio/netbird/blob/93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c/management/server/posture/checks.go#L283-L319","documentation":"Returned by Checks.Validate (management/server/posture/checks.go:301): every posture check definition must carry a human-readable name; it is the identifier operators see in policies and the dashboard. The validation runs when a posture check is created or updated through the management API.","triggerScenarios":"POST /api/posture-checks (or PUT) with an empty or missing name field in the request body.","commonSituations":"Automation/Terraform-style scripts building the payload dynamically with an unset name variable; UI form submitted before the name input is filled; API clients that omit optional-looking fields.","solutions":["Set a non-empty name (e.g. \"Require NetBird client 0.50+\") in the posture check payload","If generating payloads from templates, add a required-field check for name before sending"],"exampleFix":"// before\n{ \"name\": \"\", \"description\": \"ver\", \"checks\": { \"nb_version_check\": { \"min_version\": \"0.50.0\" } } }\n\n// after\n{ \"name\": \"Min agent version\", \"description\": \"ver\", \"checks\": { \"nb_version_check\": { \"min_version\": \"0.50.0\" } } }","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(req.Name) == \"\" {\n    return errors.New(\"posture check name is required\")\n}","typeGuard":null,"tryCatchPattern":"_, err := postureAPI.CreateCheck(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"name shouldn't be empty\") {\n        // surface a form error on the name field\n    }\n    return err\n}","preventionTips":["Treat name as a required field in every payload builder; add schema validation (required: [name]) to client models","In dashboards, disable submit until name is non-empty","Add integration tests that POST a nameless check and assert the 400, so regressions in client validation are caught"],"tags":["management","api","posture","validation"],"backgroundTag":null,"analyzedSha":"93e97f4bf1ad715072dcb3fb6cdb1763431b5a9c","analyzedAt":"2026-08-16T03:09:19.136Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}