{"record":{"id":"d86eaf3e8b5977e0","repo":"OpenNHP/opennhp","slug":"aspid-not-found","errorCode":null,"errorMessage":"aspId not found","messagePattern":"aspId not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/server/udpserver.go","lineNumber":1117,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (s *UdpServer) AddResource(res *common.ResourceData) error {\n\tif len(res.AuthServiceId) == 0 || len(res.ResourceId) == 0 {\n\t\treturn fmt.Errorf(\"aspId or resId is empty\")\n\t}\n\n\ts.authServiceMapMutex.Lock()\n\taspData, found := s.authServiceMap[res.AuthServiceId]\n\tif !found {\n\t\ts.authServiceMapMutex.Unlock()\n\t\treturn fmt.Errorf(\"aspId not found\")\n\t}\n\taspData.ResourceGroups[res.ResourceId] = res\n\ts.authServiceMapMutex.Unlock()\n\n\treturn nil\n}\n\nfunc (s *UdpServer) ValidatePlugin(h plugins.PluginHandler) bool {\n\t// placeholder to validate plugin file\n\t// err = checkSignature(s.Signature())\n\t// if err != nil {\n\t//   return false\n\t// }\n\n\treturn true\n}\n\nfunc (s *UdpServer) LoadPlugin(pluginId string, h plugins.PluginHandler) error {","sourceCodeStart":1099,"sourceCodeEnd":1135,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/server/udpserver.go#L1099-L1135","documentation":"AddResource looks up the parent AuthServiceProviderData by res.AuthServiceId in authServiceMap; if no ASP with that id has been added, the resource has nowhere to be attached and the call fails with 'aspId not found'.","triggerScenarios":"Calling UdpServer.AddResource with an AuthServiceId that was never registered via AddAuthService (or was registered after the resource).","commonSituations":"resource.toml referencing an ASP id that only exists in a different server's config; typos in the ASP id; ordering bugs where AddResource runs before AddAuthService during plugin init; stale config after renaming an ASP.","solutions":["Call AddAuthService for the ASP before adding any resources that reference its id","Make the resource's AuthServiceId exactly match an existing AuthSvcId (check for typos/case)","Align the ASP table in config.toml/resource.toml with the ids used in resource entries","Re-deploy configs together if the ASP was renamed on some replicas but not others"],"exampleFix":"// before\nsrv.AddResource(&common.ResourceData{AuthServiceId: \"aspA\", ResourceId: \"r1\"}) // aspA never registered\n// after\nsrv.AddAuthService(&common.AuthServiceProviderData{AuthSvcId: \"aspA\", ...})\nsrv.AddResource(&common.ResourceData{AuthServiceId: \"aspA\", ResourceId: \"r1\"})","handlingStrategy":"validation","validationCode":"// ensure the ASP is registered before adding resources\nif _, found := registeredASPs[res.AuthServiceId]; !found {\n    return fmt.Errorf(\"ASP %q must be added via AddAuthService before resources\", res.AuthServiceId)\n}\nerr := srv.AddResource(res)","typeGuard":null,"tryCatchPattern":"if err := srv.AddResource(res); err != nil {\n    if strings.Contains(err.Error(), \"aspId not found\") {\n        return fmt.Errorf(\"resource %q references unknown ASP %q — check resource.toml ids\", res.ResourceId, res.AuthServiceId)\n    }\n    return err\n}","preventionTips":["Enforce registration order: all AddAuthService calls before any AddResource call","Generate resource.toml ASP references from the same source of truth as the ASP ids","Grep-diff ASP ids in resource.toml against config.toml during CI"],"tags":["lookup","config","resource"],"backgroundTag":"entity-not-found","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"}