OpenNHP/opennhp · error
aspId or resId is empty
Error message
aspId or resId is empty
What it means
AddResource requires both ResourceData.AuthServiceId (which ASP owns it) and ResourceData.ResourceId (its key in the ASP's ResourceGroups map). If either string is empty the resource cannot be filed, so it is rejected up front.
Solutions
- Populate both AuthServiceId and ResourceId on the ResourceData before the call
- Fix the resource.toml entry so both fields are present and non-empty
- Validate the ResourceData at construction time and skip/defect log invalid entries
Example fix
// before
srv.AddResource(&common.ResourceData{AuthServiceId: "asp-1"})
// after
srv.AddResource(&common.ResourceData{AuthServiceId: "asp-1", ResourceId: "web-portal"}) Defensive patterns
Strategy: validation
Validate before calling
func validResource(r *common.ResourceData) bool {
return r != nil && r.AuthServiceId != "" && r.ResourceId != ""
}
if !validResource(res) { return errors.New("resource needs AuthServiceId and ResourceId") }
err := srv.AddResource(res) Type guard
func resourceIsComplete(r *common.ResourceData) bool { return r != nil && len(r.AuthServiceId) > 0 && len(r.ResourceId) > 0 } Try / catch
if err := srv.AddResource(res); err != nil {
return fmt.Errorf("AddResource(asp=%q, res=%q): %w", res.AuthServiceId, res.ResourceId, err)
} Prevention
- Validate ResourceData immediately after config decode
- Keep resource.toml field names in sync with the ResourceData struct
- Fail the deploy if any resource entry lacks either id
When it happens
Trigger: Calling UdpServer.AddResource with a *common.ResourceData where AuthServiceId == "" or ResourceId == "".
Common situations: TOML resource entries missing the resourceId key; plugins building ResourceData from partial JSON where one field is absent; renaming a resource field in config and not updating the loader mapping.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- cluster : missing publicKeyBase64
- cluster ( ): no instances configured
- cluster instance # : must set either Host or Ip
- cluster instance # : invalid port
- relay: privateKeyBase64 must be set in config
AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07).
Data as JSON: /api/errors/370e4d21431e4d3c.
Report an issue: GitHub.
Appendix: source
Thrown at endpoints/server/udpserver.go:1110
s.authServiceMap[aspData.AuthSvcId] = aspData
s.authServiceMapMutex.Unlock()
if len(aspData.PluginPath) > 0 {
h := plugins.ReadPluginHandler(aspData.PluginPath)
if h != nil {
err := s.LoadPlugin(aspData.AuthSvcId, h)
if err != nil {
return err
}
}
}
return nil
}
func (s *UdpServer) AddResource(res *common.ResourceData) error {
if len(res.AuthServiceId) == 0 || len(res.ResourceId) == 0 {
return fmt.Errorf("aspId or resId is empty")
}
s.authServiceMapMutex.Lock()
aspData, found := s.authServiceMap[res.AuthServiceId]
if !found {
s.authServiceMapMutex.Unlock()
return fmt.Errorf("aspId not found")
}
aspData.ResourceGroups[res.ResourceId] = res
s.authServiceMapMutex.Unlock()
return nil
}
func (s *UdpServer) ValidatePlugin(h plugins.PluginHandler) bool {
// placeholder to validate plugin file
// err = checkSignature(s.Signature())
// if err != nil {View on GitHub (pinned to 6e04ca5ff0)