{"record":{"id":"1a90f085ef02df32","repo":"OpenNHP/opennhp","slug":"resource-not-found","errorCode":null,"errorMessage":"resource not found","messagePattern":"resource not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"endpoints/server/kbs/resource/resource.go","lineNumber":178,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to get base directory absolute path: %w\", err)\n\t}\n\n\tfullPath := filepath.Join(absBaseDir, resourceID)\n\n\tabsFullPath, err := filepath.Abs(fullPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to get resource absolute path: %w\", err)\n\t}\n\n\t// Check if the path is within the base directory to avoid path traversal attack.\n\tif !strings.HasPrefix(absFullPath, absBaseDir) {\n\t\treturn nil, errors.New(\"invalid resource ID: potential path traversal attack\")\n\t}\n\n\tif _, statErr := os.Stat(absFullPath); statErr != nil {\n\t\tif os.IsNotExist(statErr) {\n\t\t\treturn nil, errors.New(\"resource not found\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"fail to check resource: %w\", statErr)\n\t}\n\n\tdata, err := os.ReadFile(absFullPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to read resource: %w\", err)\n\t}\n\treturn data, nil\n}\n\nfunc encryptWithA256GCM(key, plaintext []byte) (ciphertext, iv, tag []byte, err error) {\n\tblock, err := aes.NewCipher(key)\n\tif err != nil {\n\t\treturn nil, nil, nil, err\n\t}\n\n\tgcm, err := cipher.NewGCM(block)","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/server/kbs/resource/resource.go#L160-L196","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nGetResource(token, \"default/tee/attestation/mykey\") // file absent\n// after\n// copy mykey into the repo dir, then:\nGetResource(token, \"default/tee/attestation/mykey\")","handlingStrategy":"fallback","validationCode":"if _, err := os.Stat(filepath.Join(baseDir, id)); os.IsNotExist(err) {\n    return fmt.Errorf(\"resource %q not deployed to KBS repo\", id)\n}","typeGuard":null,"tryCatchPattern":"res, err := GetResource(token, id)\nif err != nil {\n    if strings.Contains(err.Error(), \"resource not found\") {\n        return fmt.Errorf(\"check repository segments and server-side files: %w\", err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["go","filesystem","kbs"],"backgroundTag":"file-not-found","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"}