{"record":{"id":"45405f41794496da","repo":"NationalSecurityAgency/ghidra","slug":"self-score-not-recorded-for","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/TableScoreCaching.java","lineNumber":163,"sourceCode":"\t\t}\n\t}\n\n\t@Override\n\tpublic float getSelfScore(String md5) throws LSHException {\n\t\tinitialize();\n\t\tFloat val = cacheMap.get(md5);\n\t\tif (val != null) {\n\t\t\treturn val.floatValue();\n\t\t}\n\t\tsetUpQuery(1);\n\t\tqueryValue.keys[0] = md5;\n\t\tResponseOptionalValues response = queryValue.execute(db);\n\t\tif (response == null) {\n\t\t\tthrow new LSHException(db.getLastError().message);\n\t\t}\n\t\tval = (Float) response.resultArray[0];\n\t\tif (val == null) {\n\t\t\tthrow new LSHException(\"Self-score not recorded for \" + md5);\n\t\t}\n\t\tcacheMap.put(md5, val);\n\t\treturn val.floatValue();\n\t}\n\n\t@Override\n\tpublic void commitSelfScore(String md5, float score) throws LSHException {\n\t\tinitialize();\n\t\tFloat val = score;\n\t\tcacheMap.put(md5, val);\n\t\tsetUpInsert(1);\n\t\tinsertValue.keys[0] = md5;\n\t\tinsertValue.values[0] = val;\n\t\tResponseOptionalExist response = insertValue.execute(db);\n\t\tif (response == null) {\n\t\t\tthrow new LSHException(db.getLastError().message);\n\t\t}\n\t}","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/TableScoreCaching.java#L145-L181","documentation":"Thrown by TableScoreCaching.getSelfScore when a BSim database query for a function's self-score (auto-similarity) returns a null result row for the given md5 vector key. The self-score is an optional per-feature-vector value stored in a dedicated optional table; this error means the requested vector exists but its self-score was never computed/committed. It indicates missing analytic metadata rather than a corrupt vector.","triggerScenarios":"Calling getSelfScore(md5) on a TableScoreCaching instance (backed by a SQL BSim database) where the md5 has no row in the optional score table. Happens when vectors were inserted without a preceding generate-self-score pass, or when querying self-scores for functions added after the last scoring run. Also if queryValue.execute(db) returns a response whose resultArray[0] is null (row exists but value column is null).","commonSituations":"Running a BSim similarity query that needs self-scores for normalization before the database has been populated with self-scores. Mixing databases where one was scored and another was not. Importing executables into a BSim database but forgetting to run the self-score generation step. Partial database migrations that copy vectors but not the optional score table.","solutions":["Run the BSim self-score generation pass over the database (generate and commitSelfScore for each vector) before issuing queries that require self-scores.","Check that the md5 actually corresponds to a vector present in the database; a vector without a self-score row triggers this.","Verify the optional score table (TABLE_NAME in TableScoreCaching) exists and is populated — if the table is absent or empty, scores were never recorded.","If you control the insertion pipeline, ensure commitSelfScore is called for every vector right after insertion."],"exampleFix":"// before\nfloat score = scoreCaching.getSelfScore(md5); // throws if unscored\n\n// after\nif (scoreCaching instanceof TemporaryScoreCaching) {\n    // in-memory cache; ensure scores committed first\n}\ntry {\n    float score = scoreCaching.getSelfScore(md5);\n} catch (LSHException e) {\n    // generate and store the self-score, then retry\n    float score = generateSelfScore(md5);\n    scoreCaching.commitSelfScore(md5, score);\n}","handlingStrategy":"validation","validationCode":"// Before querying self-scores, ensure the vector was scored.\n// For TableScoreCaching there is no public contains(); wrap in try-catch\n// and generate the score on miss.\nboolean scored = isVectorScored(md5); // app-level tracking\nif (!scored) {\n    float s = generateSelfScore(md5);\n    scoreCaching.commitSelfScore(md5, s);\n}","typeGuard":null,"tryCatchPattern":"try {\n    float score = scoreCaching.getSelfScore(md5);\n} catch (LSHException e) {\n    if (e.getMessage().startsWith(\"Self-score not recorded\")) {\n        float s = generateSelfScore(md5);\n        scoreCaching.commitSelfScore(md5, s);\n        // retry once\n        score = scoreCaching.getSelfScore(md5);\n    } else throw e;\n}","preventionTips":["Always run self-score generation as part of the vector insertion pipeline.","For TemporaryScoreCaching, pre-populate all scores in one pass before any query.","Track which md5s have been scored in an app-level set to avoid repeated miss handling."],"tags":["bsim","database","self-score","lsh-exception","missing-data"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}