{"record":{"id":"e548c5dea46cec65","repo":"NationalSecurityAgency/ghidra","slug":"self-score-not-recorded-for-e548c5","errorCode":null,"errorMessage":"Self-score not recorded for ","messagePattern":"Self-score not recorded for ","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TemporaryScoreCaching.java","lineNumber":67,"sourceCode":"\t\t\telse {\n\t\t\t\tfor (ExecutableRecord exeRec : exeSet) {\n\t\t\t\t\tif (!cacheMap.containsKey(exeRec.getMd5())) {\n\t\t\t\t\t\tmissing.add(exeRec);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic float getSelfScore(String md5) throws LSHException {\n\t\tif (cacheMap != null) {\n\t\t\tFloat val = cacheMap.get(md5);\n\t\t\tif (val != null) {\n\t\t\t\treturn val.floatValue();\n\t\t\t}\n\t\t}\n\t\tthrow new LSHException(\"Self-score not recorded for \" + md5);\n\t}\n\n\t@Override\n\tpublic void commitSelfScore(String md5, float score) throws LSHException {\n\t\tif (cacheMap == null) {\n\t\t\tcacheMap = new TreeMap<String, Float>();\n\t\t}\n\t\tcacheMap.put(md5, score);\n\t}\n\n\t@Override\n\tpublic double getSimThreshold() throws LSHException {\n\t\treturn simThreshold;\n\t}\n\n\t@Override\n\tpublic double getSigThreshold() throws LSHException {\n\t\treturn sigThreshold;","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TemporaryScoreCaching.java#L49-L85","documentation":"Thrown by TemporaryScoreCaching.getSelfScore when the in-memory cache (TreeMap) does not contain an entry for the given md5. Unlike TableScoreCaching, TemporaryScoreCaching has no database fallback — it only serves scores that were explicitly committed into memory. A cache miss is therefore a hard error. This is used for transient/ephemeral scoring sessions.","triggerScenarios":"Calling getSelfScore(md5) on a TemporaryScoreCaching before commitSelfScore(md5, score) has been called for that md5. Also when the cache was reset (cacheMap set to null or cleared) between commit and query. Any code path that queries a self-score it never stored.","commonSituations":"Using a TemporaryScoreCaching for a short-lived scoring session but querying a vector whose score was computed in a different session/cache instance. Forgetting to populate the cache for all vectors in a batch before issuing similarity queries that read self-scores. Resetting the cache mid-run.","solutions":["Ensure commitSelfScore is called for every md5 you intend to query before calling getSelfScore.","If you need persistence across sessions, use TableScoreCaching (database-backed) instead of TemporaryScoreCaching.","Pre-populate the cache in a single pass: iterate all vectors, compute self-scores, commit, then query.","Guard with a contains check if the cache exposes it, or maintain your own set of scored md5s."],"exampleFix":"// before\nTemporaryScoreCaching cache = new TemporaryScoreCaching();\nfloat s = cache.getSelfScore(md5); // throws — never committed\n\n// after\nTemporaryScoreCaching cache = new TemporaryScoreCaching();\nfor (String id : allMd5s) {\n    cache.commitSelfScore(id, computeSelfScore(id));\n}\nfloat s = cache.getSelfScore(md5);","handlingStrategy":"validation","validationCode":"// Track scored md5s to validate before querying a TemporaryScoreCaching.\nSet<String> scored = new HashSet<>();\nvoid commit(String md5, float s) { cache.commitSelfScore(md5, s); scored.add(md5); }\nfloat get(String md5) throws LSHException {\n    if (!scored.contains(md5)) throw new IllegalStateException(\"unscored: \"+md5);\n    return cache.getSelfScore(md5);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return cache.getSelfScore(md5);\n} catch (LSHException e) {\n    // No DB fallback for TemporaryScoreCaching; generate and commit\n    float s = generateSelfScore(md5);\n    cache.commitSelfScore(md5, s);\n    return cache.getSelfScore(md5);\n}","preventionTips":["For TemporaryScoreCaching, commit all scores before any query.","Switch to TableScoreCaching if you need cross-session persistence.","Maintain an app-level set of committed md5s to validate cheaply."],"tags":["bsim","self-score","in-memory-cache","lsh-exception","missing-data"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}