{"record":{"id":"89e6558f5dbe5755","repo":"OpenNHP/opennhp","slug":"aspid-is-empty","errorCode":null,"errorMessage":"aspId is empty","messagePattern":"aspId is empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/server/udpserver.go","lineNumber":1088,"sourceCode":"\t\ts.acPeerMapMutex.Unlock()\n\t}\n}\n\nfunc (s *UdpServer) AddAddressAssociation(srcIp string, addrs []*common.NetAddress) {\n\ts.srcIpAssociatedAddrMapMutex.Lock()\n\ts.srcIpAssociatedAddrMap[srcIp] = addrs\n\ts.srcIpAssociatedAddrMapMutex.Unlock()\n}\n\nfunc (s *UdpServer) RemoveAddressAssociation(srcIp string) {\n\ts.srcIpAssociatedAddrMapMutex.Lock()\n\tdelete(s.srcIpAssociatedAddrMap, srcIp)\n\ts.srcIpAssociatedAddrMapMutex.Unlock()\n}\n\nfunc (s *UdpServer) AddAuthService(aspData *common.AuthServiceProviderData) error {\n\tif len(aspData.AuthSvcId) == 0 {\n\t\treturn fmt.Errorf(\"aspId is empty\")\n\t}\n\n\ts.authServiceMapMutex.Lock()\n\ts.authServiceMap[aspData.AuthSvcId] = aspData\n\ts.authServiceMapMutex.Unlock()\n\n\tif len(aspData.PluginPath) > 0 {\n\t\th := plugins.ReadPluginHandler(aspData.PluginPath)\n\t\tif h != nil {\n\t\t\terr := s.LoadPlugin(aspData.AuthSvcId, h)\n\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}","sourceCodeStart":1070,"sourceCodeEnd":1106,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/server/udpserver.go#L1070-L1106","documentation":"AddAuthService validates that AuthServiceProviderData.AuthSvcId is non-empty before inserting into authServiceMap. An auth service provider without an identifier cannot be referenced by resources, so it is rejected.","triggerScenarios":"Calling UdpServer.AddAuthService with a *common.AuthServiceProviderData whose AuthSvcId field is \"\" (zero-length).","commonSituations":"Plugins or config loaders constructing AuthServiceProviderData programmatically and forgetting to set AuthSvcId; TOML keys misnamed so the id field never gets populated; a decoded config struct defaulting to empty string.","solutions":["Set AuthSvcId on the AuthServiceProviderData before calling AddAuthService","Check the resource/asp config file for a misspelled or missing id key so the field decodes correctly","Log/skip the offending aspData at the construction site instead of passing it to AddAuthService"],"exampleFix":"// before\nsrv.AddAuthService(&common.AuthServiceProviderData{AuthSvcUrl: \"https://asp\"})\n// after\nsrv.AddAuthService(&common.AuthServiceProviderData{AuthSvcId: \"asp-1\", AuthSvcUrl: \"https://asp\"})","handlingStrategy":"validation","validationCode":"func validASP(d *common.AuthServiceProviderData) bool { return d != nil && d.AuthSvcId != \"\" }\nif !validASP(aspData) { return errors.New(\"skip: AuthSvcId required\") }\nerr := srv.AddAuthService(aspData)","typeGuard":"func aspHasID(d *common.AuthServiceProviderData) bool { return d != nil && len(d.AuthSvcId) > 0 }","tryCatchPattern":"if err := srv.AddAuthService(aspData); err != nil {\n    return fmt.Errorf(\"AddAuthService(%q): %w\", aspData.AuthSvcId, err)\n}","preventionTips":["Always set AuthSvcId at struct construction, never leave it to later filling","Validate ASP entries right after TOML decode, before they reach the server","Use a shared constructor that requires the id parameter"],"tags":["validation","config"],"backgroundTag":"empty-required-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"}