OpenNHP/opennhp · error

aspId not found

Error message

aspId not found

What it means

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'.

Solutions

  1. Call AddAuthService for the ASP before adding any resources that reference its id
  2. Make the resource's AuthServiceId exactly match an existing AuthSvcId (check for typos/case)
  3. Align the ASP table in config.toml/resource.toml with the ids used in resource entries
  4. Re-deploy configs together if the ASP was renamed on some replicas but not others

Example fix

// before
srv.AddResource(&common.ResourceData{AuthServiceId: "aspA", ResourceId: "r1"}) // aspA never registered
// after
srv.AddAuthService(&common.AuthServiceProviderData{AuthSvcId: "aspA", ...})
srv.AddResource(&common.ResourceData{AuthServiceId: "aspA", ResourceId: "r1"})
Defensive patterns

Strategy: validation

Validate before calling

// ensure the ASP is registered before adding resources
if _, found := registeredASPs[res.AuthServiceId]; !found {
    return fmt.Errorf("ASP %q must be added via AddAuthService before resources", res.AuthServiceId)
}
err := srv.AddResource(res)

Try / catch

if err := srv.AddResource(res); err != nil {
    if strings.Contains(err.Error(), "aspId not found") {
        return fmt.Errorf("resource %q references unknown ASP %q — check resource.toml ids", res.ResourceId, res.AuthServiceId)
    }
    return err
}

Prevention

When it happens

Trigger: Calling UdpServer.AddResource with an AuthServiceId that was never registered via AddAuthService (or was registered after the resource).

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

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at endpoints/server/udpserver.go:1117

			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 {
	//   return false
	// }

	return true
}

func (s *UdpServer) LoadPlugin(pluginId string, h plugins.PluginHandler) error {

View on GitHub (pinned to 6e04ca5ff0)