{"record":{"id":"82708487459877a8","repo":"NationalSecurityAgency/ghidra","slug":"executablerecord-does-not-have-id","errorCode":null,"errorMessage":"ExecutableRecord does not have id","messagePattern":"ExecutableRecord does not have id","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeToCategoryTable.java","lineNumber":141,"sourceCode":"\t\t\tString type = catstringtable.getString(row.id_type);\n\t\t\tString category = catstringtable.getString(row.id_category);\n\t\t\tCategoryRecord catrec = new CategoryRecord(type, category);\n\t\t\tvecres.add(catrec);\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @param exeid the executable table id\n\t * @param max the max number of records to return\n\t * @return the list of category records\n\t * @throws SQLException if there is a problem creating or executing the query\n\t */\n\tpublic List<CategoryRecord> queryExecutableCategories(long exeid, int max)\n\t\tthrows SQLException {\n\n\t\tif (exeid == 0) {\n\t\t\tthrow new SQLException(\"ExecutableRecord does not have id\");\n\t\t}\n\n\t\tPreparedStatement s =\n\t\t\tselectCategoriesStatement.prepareIfNeeded(() -> db.prepareStatement(SELECT_STMT));\n\t\ts.setInt(1, (int) exeid);\n\t\ttry (ResultSet rs = s.executeQuery()) {\n\t\t\tList<CategoryRecord> catvec = new ArrayList<CategoryRecord>();\n\t\t\textractCategoryRecords(rs, catvec, max);\n\t\t\treturn catvec;\n\t\t}\n\t}\n\n\t/**\n\t * \n\t * @param erec the executable record\n\t * @throws SQLException if there is a problem inserting the category \n\t */\n\tpublic void storeExecutableCategories(ExecutableRecord erec) throws SQLException {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/tables/ExeToCategoryTable.java#L123-L159","documentation":"Thrown by ExeToCategoryTable.queryExecutableCategories when the exeid parameter is 0, which the code treats as 'no id'. An ExecutableRecord with a zero/null-equivalent id has not been persisted to the database, so querying its categories is invalid. Category lookups require a real exetable row id.","triggerScenarios":"Calling queryExecutableCategories(0, max) — passing an exeid of 0. Happens when an ExecutableRecord's row id was never assigned (still 0/unset) and the caller forwards it directly. The guard uses 0 (not null) because the parameter is a primitive long.","commonSituations":"Using a freshly constructed ExecutableRecord that has not been inserted (id defaults to 0). Forgetting to persist the executable before querying its categories. Reading an id field that was never populated after insert (insert path failed to set it).","solutions":["Ensure the ExecutableRecord has been inserted and assigned a non-zero row id before querying categories.","Validate exeid != 0 upstream and throw a clearer error or skip.","After insert, confirm the returned/generated id is set on the record object.","Trace the insert path to verify id assignment (related to errors 811/807)."],"exampleFix":"// before\nList<CategoryRecord> cats = table.queryExecutableCategories(exeRec.getRowId(), max); // id==0\n\n// after\nlong exeid = exeRec.getRowId();\nif (exeid == 0) {\n    throw new IllegalStateException(\"ExecutableRecord not persisted; row id is 0\");\n}\nList<CategoryRecord> cats = table.queryExecutableCategories(exeid, max);","handlingStrategy":"validation","validationCode":"// Validate the executable id is set before category lookup.\nlong exeid = exeRec.getRowId();\nif (exeid == 0) {\n    throw new IllegalStateException(\"ExecutableRecord not persisted (id==0)\");\n}\nreturn table.queryExecutableCategories(exeid, max);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always persist an ExecutableRecord before querying its categories.","After insert, confirm the row id is assigned to the record.","Treat an id of 0 as 'unset' and validate against it."],"tags":["bsim","database","categories","null-id","validation","sql-exception"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}