{"record":{"id":"9d3477110aab6b26","repo":"OpenNHP/opennhp","slug":"no-server-cluster-set-cluster-in-resource-toml-or","errorCode":null,"errorMessage":"no server cluster: set Cluster in resource.toml or use --server","messagePattern":"no server cluster: set Cluster in resource\\.toml or use --server","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/agent/main/main.go","lineNumber":577,"sourceCode":"\tif serverCluster != \"\" {\n\t\tres.Cluster = serverCluster\n\t} else {\n\t\tkt := a.FindKnockTarget(aspId, resId)\n\t\tif kt == nil {\n\t\t\tkt = a.FindKnockTargetByAspId(aspId)\n\t\t}\n\t\tif kt != nil {\n\t\t\tsc := kt.GetServerCluster()\n\t\t\tif sc != nil {\n\t\t\t\tres.Cluster = sc.Name\n\t\t\t}\n\t\t}\n\t}\n\n\tif res.Cluster == \"\" && res.ServerPubKey == \"\" {\n\t\tfmt.Printf(\"  %s❌ No server cluster found for asp-id=%q%s\\n\", colorYellow, aspId, colorReset)\n\t\tfmt.Printf(\"  %sHint: configure a matching [[Resources]] entry in resource.toml or pass --server <cluster-name>%s\\n\\n\", colorDim, colorReset)\n\t\treturn fmt.Errorf(\"no server cluster: set Cluster in resource.toml or use --server\")\n\t}\n\n\tsc, err := a.FindServerClusterFromResource(res)\n\tif err != nil {\n\t\tfmt.Printf(\"  %s❌ Cannot resolve server cluster %q: %v%s\\n\\n\", colorYellow, res.Cluster, err, colorReset)\n\t\tfmt.Printf(\"  %sHint: ensure the cluster name matches a [[Servers]] Name in server.toml%s\\n\\n\", colorDim, colorReset)\n\t\treturn err\n\t}\n\n\ttarget := &agent.KnockTarget{\n\t\tKnockResource: *res,\n\t\tServerPeer:    sc.RepresentativePeer(),\n\t\tServerCluster: sc,\n\t}\n\n\t// Step 1: OTP request (skipped when --otp is provided).\n\tif otpCode == \"\" {\n\t\tfmt.Printf(\"  %sStep 1/2:%s Requesting OTP from server...\\n\", colorBlue, colorReset)","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/agent/main/main.go#L559-L595","documentation":"runRegisterApp resolves which server cluster should handle registration for the given asp-id. If the resolved Resource has neither Cluster nor ServerPubKey set, there is no routing target for the knock, so the command prints a hint and returns this error.","triggerScenarios":"runRegisterApp with res.Cluster == \"\" && res.ServerPubKey == \"\" — no [[Resources]] entry in resource.toml matches the entered asp-id, and no --server <cluster-name> flag was passed.","commonSituations":"Typo in asp-id so it matches no resource entry; resource.toml entry lacking a Cluster field; running registration on a machine whose resource.toml was never deployed; forgetting --server when multiple clusters exist.","solutions":["Add/fix the [[Resources]] entry in resource.toml so its AuthServiceProviderId matches the entered asp-id and set its Cluster.","Pass --server <cluster-name> on the register command to target a cluster defined in server.toml explicitly.","Verify the cluster name matches a [[Servers]] Name in server.toml.","Confirm the agent is reading the resource.toml you edited (check the config directory it loads)."],"exampleFix":"// before (resource.toml)\n[[Resources]]\nAuthServiceProviderId = \"my-app\"\n# no Cluster\n\n// after\n[[Resources]]\nAuthServiceProviderId = \"my-app\"\nCluster = \"nhp-server-cluster\"","handlingStrategy":"validation","validationCode":"res := findResourceByAspId(aspId)\nif res == nil || (res.Cluster == \"\" && res.ServerPubKey == \"\") {\n    return fmt.Errorf(\"no server cluster for asp-id %q; set Cluster in resource.toml or pass --server\", aspId)\n}","typeGuard":null,"tryCatchPattern":"sc, err := a.FindServerClusterFromResource(res)\nif err != nil {\n    return fmt.Errorf(\"resolve cluster: %w\", err)\n}","preventionTips":["Give every [[Resources]] entry a Cluster matching a [[Servers]] Name in server.toml.","Deploy resource.toml alongside agent config before registering.","Use --server when resource.toml is incomplete or ambiguous."],"tags":["config","registration","routing","go"],"backgroundTag":"missing-required-config-field","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}