{"record":{"id":"afc5fc4ff54ce353","repo":"NationalSecurityAgency/ghidra","slug":"selected-file-is-not-a-program","errorCode":null,"errorMessage":"Selected file is not a program","messagePattern":"Selected file is not a program","errorType":"exception","errorClass":"LoadException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-importers/src/main/java/ghidra/app/util/opinion/TenetLoader.java","lineNumber":276,"sourceCode":"\t\tTrace trace;\n\t\tString programPath = null;\n\n\t\tfor (final Option option : settings.options()) {\n\t\t\tfinal String name = option.getName();\n\t\t\tif (name.equals(DOMAIN_FILE_OPTION_NAME)) {\n\t\t\t\tprogramPath = (String) option.getValue();\n\t\t\t}\n\t\t}\n\n\t\tif ((programPath == null) || programPath.isBlank()) {\n\t\t\tthrow new LoadException(\"No progam to associate with trace was given\");\n\t\t}\n\n\t\tMsg.info(this, \"Loading trace for %s\".formatted(programPath));\n\n\t\tfinal DomainFile df = settings.project().getProjectData().getFile(programPath);\n\t\tif (!df.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) {\n\t\t\tthrow new LoadException(\"Selected file is not a program\");\n\t\t}\n\t\tProgram program = null;\n\n\t\ttry {\n\t\t\tprogram = (Program) df.getDomainObject(this, false, false, settings.monitor());\n\n\t\t\tfinal long start = System.currentTimeMillis();\n\n\t\t\ttrace = loadTrace(settings.provider(), settings.importName(), program,\n\t\t\t\tsettings.consumer(), settings.log(), settings.monitor());\n\n\t\t\tfinal long loadDone = System.currentTimeMillis();\n\n\t\t\t// TODO: This is needed because\n\t\t\t// ghidra.trace.database.DBTraceContentHandler.createFile can't do\n\t\t\t// it, due to a lock in\n\t\t\t// ghidra.framework.data.GhidraFolderData.createFile\n\t\t\tfinal DBTraceObjectManager objManager = (DBTraceObjectManager) trace.getObjectManager();","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-importers/src/main/java/ghidra/app/util/opinion/TenetLoader.java#L258-L294","documentation":"LoadException from TenetLoader after resolving the named domain file: it checks df.getContentType() against ProgramContentHandler.PROGRAM_CONTENT_TYPE and throws if they differ. The selected file must be a Ghidra Program; a Trace, data-type archive, folder, or other content type is rejected.","triggerScenarios":"DOMAIN_FILE_OPTION_NAME points at a domain file whose content type is not a Program (e.g. a previously imported Trace, a .gdt archive, a folder). Resolved via settings.project().getProjectData().getFile(programPath).","commonSituations":"User selects the trace's own file or an archive instead of the executable program in the import dialog; wrong path string that resolves to a non-program domain object; selecting a project folder rather than a leaf program file.","solutions":["Point DOMAIN_FILE_OPTION_NAME at a domain file whose content type equals ProgramContentHandler.PROGRAM_CONTENT_TYPE.","Before loading, resolve the DomainFile and assert its getContentType() is the Program content type, surfacing a clearer message to the user.","Re-import or open the intended executable as a Program first, then reference that domain file path."],"exampleFix":"// before\n// (user picks an archive .gdt as the associated program)\n\n// after\nDomainFile df = project.getProjectData().getFile(programPath);\nif (!ProgramContentHandler.PROGRAM_CONTENT_TYPE.equals(df.getContentType())) {\n    throw new IllegalArgumentException(programPath + \" is not a Program; pick the executable\");\n}","handlingStrategy":"validation","validationCode":"DomainFile df = project.getProjectData().getFile(programPath);\nif (df == null || !ProgramContentHandler.PROGRAM_CONTENT_TYPE.equals(df.getContentType())) {\n    throw new IllegalArgumentException(programPath + \" is not a Program\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    loader.load(settings);\n} catch (LoadException e) {\n    if (e.getMessage().contains(\"not a program\")) {\n        // re-prompt for a Program domain file\n    }\n}","preventionTips":["Verify the domain file content type is Program before associating it with a trace.","Do not point the loader at archives (.gdt), traces, or folders.","In the GUI, filter the file picker to Program content."],"tags":["ghidra","import","loader","program","trace","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}