{"record":{"id":"1c45720af4ec2d6e","repo":"NationalSecurityAgency/ghidra","slug":"function-list-cannot-be-null-1c4572","errorCode":null,"errorMessage":"Function list cannot be null","messagePattern":"Function list cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SFQueryInfo.java","lineNumber":56,"sourceCode":"\tpublic static final int DEFAULT_QUERIES_PER_STAGE = 10;\n\n\tprivate Set<FunctionSymbol> functions;\n\tprivate Program program;\n\n\tprivate QueryNearest queryNearest;\n\tprivate BSimFilter bsimFilter;\n\tprivate PreFilter preFilter;\n\n\t/**\n\t * Constructs a query request with default parameters.\n\t * @param functions required--a set of functions (at least one) for which similar functions\n\t *                  will searched.  All functions must be from the same program.\n\t * @throws IllegalArgumentException if {@code functions} is {@code null}/empty or functions\n\t * are from multiple programs.  \n\t */\n\tpublic SFQueryInfo(Set<FunctionSymbol> functions) {\n\t\tif (functions == null) {\n\t\t\tthrow new IllegalArgumentException(\"Function list cannot be null\");\n\t\t}\n\n\t\tif (functions.isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Function list cannot be empty\");\n\t\t}\n\n\t\tthis.functions = functions;\n\t\tfor (FunctionSymbol s : functions) {\n\t\t\tif (program == null) {\n\t\t\t\tprogram = s.getProgram();\n\t\t\t}\n\t\t\telse if (program != s.getProgram()) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"all function symbols are not from the same program\");\n\t\t\t}\n\t\t}\n\t\tqueryNearest = new QueryNearest();\n\t\tbsimFilter = new BSimFilter();","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/facade/SFQueryInfo.java#L38-L74","documentation":"Thrown by the SFQueryInfo constructor when the Set<FunctionSymbol> functions argument is null. SFQueryInfo packages a full similar-function query (QueryNearest) and mirrors SFOverviewInfo's three ordered validations (null, empty, cross-program). It is a programmer/argument error, not a runtime DB condition.","triggerScenarios":"new SFQueryInfo(null); or forwarding an unassigned selection result.","commonSituations":"A BSim search dialog/action that builds the set from a selection and forwards it without a null guard; refactoring leaving a null path.","solutions":["Null-check the selection before constructing SFQueryInfo and abort the search action with a user message.","Ensure upstream providers never return null (return empty set instead), letting the empty-check handle the message.","Use Objects.requireNonNull at the call site to fail fast with a clear cause during development."],"exampleFix":"// before\nSFQueryInfo info = new SFQueryInfo(selected);\n// after\nif (selected == null || selected.isEmpty()) {\n    setStatusMessage(\"Select one or more functions\");\n    return;\n}\nSFQueryInfo info = new SFQueryInfo(selected);","handlingStrategy":"validation","validationCode":"if (functions == null || functions.isEmpty()) {\n    setStatusMessage(\"Select one or more functions\");\n    return;\n}\nSFQueryInfo info = new SFQueryInfo(functions);","typeGuard":"static boolean hasQueryInput(Set<FunctionSymbol> fns) {\n    return fns != null && !fns.isEmpty();\n}","tryCatchPattern":"try {\n    new SFQueryInfo(functions);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"null\")) { /* prompt for selection */ }\n}","preventionTips":["Null-check selection before constructing SFQueryInfo.","Make selection providers return empty sets, never null.","Disable the search action when no functions are selected."],"tags":["bsim","facade","validation","argument-error","query"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}