OpenNHP/opennhp · error

aspId is empty

Error message

aspId is empty

What it means

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.

Solutions

  1. Set AuthSvcId on the AuthServiceProviderData before calling AddAuthService
  2. Check the resource/asp config file for a misspelled or missing id key so the field decodes correctly
  3. Log/skip the offending aspData at the construction site instead of passing it to AddAuthService

Example fix

// before
srv.AddAuthService(&common.AuthServiceProviderData{AuthSvcUrl: "https://asp"})
// after
srv.AddAuthService(&common.AuthServiceProviderData{AuthSvcId: "asp-1", AuthSvcUrl: "https://asp"})
Defensive patterns

Strategy: validation

Validate before calling

func validASP(d *common.AuthServiceProviderData) bool { return d != nil && d.AuthSvcId != "" }
if !validASP(aspData) { return errors.New("skip: AuthSvcId required") }
err := srv.AddAuthService(aspData)

Type guard

func aspHasID(d *common.AuthServiceProviderData) bool { return d != nil && len(d.AuthSvcId) > 0 }

Try / catch

if err := srv.AddAuthService(aspData); err != nil {
    return fmt.Errorf("AddAuthService(%q): %w", aspData.AuthSvcId, err)
}

Prevention

When it happens

Trigger: Calling UdpServer.AddAuthService with a *common.AuthServiceProviderData whose AuthSvcId field is "" (zero-length).

Common situations: 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.

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


AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07). Data as JSON: /api/errors/89e6558f5dbe5755. Report an issue: GitHub.

Appendix: source

Thrown at endpoints/server/udpserver.go:1088

		s.acPeerMapMutex.Unlock()
	}
}

func (s *UdpServer) AddAddressAssociation(srcIp string, addrs []*common.NetAddress) {
	s.srcIpAssociatedAddrMapMutex.Lock()
	s.srcIpAssociatedAddrMap[srcIp] = addrs
	s.srcIpAssociatedAddrMapMutex.Unlock()
}

func (s *UdpServer) RemoveAddressAssociation(srcIp string) {
	s.srcIpAssociatedAddrMapMutex.Lock()
	delete(s.srcIpAssociatedAddrMap, srcIp)
	s.srcIpAssociatedAddrMapMutex.Unlock()
}

func (s *UdpServer) AddAuthService(aspData *common.AuthServiceProviderData) error {
	if len(aspData.AuthSvcId) == 0 {
		return fmt.Errorf("aspId is empty")
	}

	s.authServiceMapMutex.Lock()
	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
}

View on GitHub (pinned to 6e04ca5ff0)