{"record":{"id":"c0e125efc5726696","repo":"NationalSecurityAgency/ghidra","slug":"unsupported-domain-object","errorCode":null,"errorMessage":"Unsupported domain object: {}","messagePattern":"Unsupported domain object: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/DBTraceContentHandler.java","lineNumber":51,"sourceCode":"import ghidra.util.exception.VersionException;\nimport ghidra.util.task.TaskMonitor;\n\npublic class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace> {\n\tpublic static final String TRACE_CONTENT_TYPE = \"Trace\";\n\n\tpublic static final Icon TRACE_ICON = Trace.TRACE_ICON;\n\n\tstatic final Class<DBTrace> TRACE_DOMAIN_OBJECT_CLASS = DBTrace.class;\n\tstatic final String TRACE_CONTENT_DEFAULT_TOOL = \"Debugger\";\n\n\tprivate static final DBTraceLinkContentHandler LINK_HANDLER = new DBTraceLinkContentHandler();\n\n\t@Override\n\tpublic long createFile(FileSystem fs, FileSystem userfs, String path, String name,\n\t\t\tDomainObject obj, TaskMonitor monitor)\n\t\t\tthrows IOException, InvalidNameException, CancelledException {\n\t\tif (!(obj instanceof DBTrace trace)) {\n\t\t\tthrow new IOException(\"Unsupported domain object: \" + obj.getClass().getName());\n\t\t}\n\t\treturn createFile(trace, TRACE_CONTENT_TYPE, fs, path, name, monitor);\n\t}\n\n\t@Override\n\tpublic DBTrace getImmutableObject(FolderItem item, Object consumer, int version,\n\t\t\tint minChangeVersion, TaskMonitor monitor)\n\t\t\tthrows IOException, CancelledException, VersionException {\n\t\tString contentType = item.getContentType();\n\t\tif (contentType != null && !contentType.equals(TRACE_CONTENT_TYPE)) {\n\t\t\tthrow new IOException(\"Unsupported content type: \" + contentType);\n\t\t}\n\t\tDatabaseItem dbItem = (DatabaseItem) item;\n\t\tManagedBufferFile bf = null;\n\t\tDBHandle dbh = null;\n\t\tDBTrace trace = null;\n\t\tboolean success = false;\n\t\ttry {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/DBTraceContentHandler.java#L33-L69","documentation":"DBTraceContentHandler.createFile persists a DomainObject as a trace file. It only accepts DBTrace instances; passing any other DomainObject (e.g. a Program, or a generic DomainObjectProxy) is rejected with IOException because the trace content schema cannot serialize it.","triggerScenarios":"Invoking contentHandler.createFile(fs, userfs, path, name, obj, monitor) where obj is a Program, DataTypeArchive, or any DomainObject that is not a DBTrace.","commonSituations":"Routing a save through the wrong content handler (handler resolution returned DBTraceContentHandler for a non-trace object). Programmatic `domainFile.save()` after the file's content type was changed/lost. Plugin wiring that assumes a trace where a program was opened.","solutions":["Ensure the DomainObject is actually a DBTrace before calling createFile (instanceof check).","Use the correct content handler for the object's actual type (e.g. ProgramContentHandler for a Program).","If the object should be a trace, construct it as a new DBTrace rather than reusing a Program."],"exampleFix":"// before: handing a Program to the trace handler\nhandler.createFile(fs, userfs, path, name, program, monitor);\n\n// after: create/save via the matching handler, or confirm the object type\nif (!(obj instanceof DBTrace)) {\n    throw new IOException(\"Not a trace: \" + obj.getClass().getName());\n}\nhandler.createFile(fs, userfs, path, name, obj, monitor);","handlingStrategy":"type-guard","validationCode":"if (!(obj instanceof DBTrace)) {\n    throw new IOException(\"Cannot save non-trace object as trace: \" + obj.getClass().getName());\n}\nhandler.createFile(fs, userfs, path, name, obj, monitor);","typeGuard":"static boolean isTraceDomainObject(DomainObject obj) {\n    return obj instanceof DBTrace;\n}","tryCatchPattern":"try {\n    return handler.createFile(fs, userfs, path, name, obj, monitor);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"Unsupported domain object\")) {\n        // route to the content handler matching obj's real type\n    } else throw e;\n}","preventionTips":["Resolve the content handler from the object's actual type, not a hardcoded handler reference.","Type-check DomainObject before save in generic save paths.","Keep file contentType and the live DomainObject type consistent across renames/conversions."],"tags":["domain-object","content-handler","trace","persistence"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}