OpenNHP/opennhp · error
resource not found
Error message
resource not found
What it means
After the traversal check passes, loadResource stats the resolved path; when os.Stat reports the file does not exist it returns this error, meaning the resource ID is well-formed but no such file exists in the repository directory.
Solutions
- Verify the file exists at <baseDir>/<repository>/<collection>/<type>/<name> on the server
- Fix the resource ID segments (spelling, case) in the client request
- Upload/copy the missing resource file into the repository directory
- Check container volume mounts map the populated resource directory
Example fix
// before GetResource(token, "default/tee/attestation/mykey") // file absent // after // copy mykey into the repo dir, then: GetResource(token, "default/tee/attestation/mykey")
Defensive patterns
Strategy: fallback
Validate before calling
if _, err := os.Stat(filepath.Join(baseDir, id)); os.IsNotExist(err) {
return fmt.Errorf("resource %q not deployed to KBS repo", id)
} Try / catch
res, err := GetResource(token, id)
if err != nil {
if strings.Contains(err.Error(), "resource not found") {
return fmt.Errorf("check repository segments and server-side files: %w", err)
}
return err
} Prevention
- Deploy resource files in the same pipeline step as the server
- Keep an inventory test listing expected files under baseDir on the host
- Verify container volume mounts contain the populated resource directory
When it happens
Trigger: GetResource called with a valid-format ID whose file was never uploaded to the resource directory, the filename casing/spelling differs, or the resource dir was mounted empty.
Common situations: Deployment forgot to copy resource files into the KBS repository path; wrong repository/collection/type/name segments in the ID; volume mount pointing at an empty directory in containers.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- could not get file info
- fail to create private key directory
- fail to create public key directory
- fail to write private key file
- fail to write public key file
AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07).
Data as JSON: /api/errors/1a90f085ef02df32.
Report an issue: GitHub.
Appendix: source
Thrown at endpoints/server/kbs/resource/resource.go:178
if err != nil {
return nil, fmt.Errorf("fail to get base directory absolute path: %w", err)
}
fullPath := filepath.Join(absBaseDir, resourceID)
absFullPath, err := filepath.Abs(fullPath)
if err != nil {
return nil, fmt.Errorf("fail to get resource absolute path: %w", err)
}
// Check if the path is within the base directory to avoid path traversal attack.
if !strings.HasPrefix(absFullPath, absBaseDir) {
return nil, errors.New("invalid resource ID: potential path traversal attack")
}
if _, statErr := os.Stat(absFullPath); statErr != nil {
if os.IsNotExist(statErr) {
return nil, errors.New("resource not found")
}
return nil, fmt.Errorf("fail to check resource: %w", statErr)
}
data, err := os.ReadFile(absFullPath)
if err != nil {
return nil, fmt.Errorf("fail to read resource: %w", err)
}
return data, nil
}
func encryptWithA256GCM(key, plaintext []byte) (ciphertext, iv, tag []byte, err error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, nil, nil, err
}
gcm, err := cipher.NewGCM(block)View on GitHub (pinned to 6e04ca5ff0)