{"record":{"id":"304180aa79603379","repo":"NationalSecurityAgency/ghidra","slug":"couldn-t-get-namespace-newsymbol-getparentnam","errorCode":null,"errorMessage":"Couldn't get namespace '\" + newSymbol.getParentNamespace().toString() + \"' in result program.","messagePattern":"Couldn't get namespace '\" \\+ newSymbol\\.getParentNamespace\\(\\)\\.toString\\(\\) \\+ \"' in result program\\.","errorType":"exception","errorClass":"InvalidInputException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/SymbolMerger.java","lineNumber":2283,"sourceCode":"\t * @param oldProgram the program containing the old symbol\n\t * @param oldSymbol the old symbol\n\t * @param newProgram the program containing the new symbol\n\t * @param newSymbol the new symbol\n\t * @throws DuplicateNameException\n\t * @throws InvalidInputException\n\t * @throws CircularDependencyException\n\t */\n\tprivate void renameSymbol(Program oldProgram, Symbol oldSymbol, Program newProgram,\n\t\t\tSymbol newSymbol)\n\t\t\tthrows DuplicateNameException, InvalidInputException, CircularDependencyException {\n\t\tSourceType source = newSymbol.getSource();\n\t\tString newName = newSymbol.getName();\n\t\tAddress addressInOldProgram =\n\t\t\tSimpleDiffUtility.getCompatibleAddress(newProgram, newSymbol.getAddress(), oldProgram);\n\t\tNamespace namespaceInOldProgram =\n\t\t\tDiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram);\n\t\tif (namespaceInOldProgram == null) {\n\t\t\tthrow new InvalidInputException(\"Couldn't get namespace '\" +\n\t\t\t\tnewSymbol.getParentNamespace().toString() + \"' in result program.\");\n\t\t}\n\t\tSymbolTable oldSymTab = oldProgram.getSymbolTable();\n\t\tSymbol existingSymbol =\n\t\t\toldSymTab.getSymbol(newName, addressInOldProgram, namespaceInOldProgram);\n\t\tif (oldSymbol == existingSymbol) {\n\t\t\treturn; // Already has correct name and scope.\n\t\t}\n\n\t\t// rename and then set namespace.\n\t\tString oldName = oldSymbol.getName();\n\t\tNamespace oldNamespace = oldSymbol.getParentNamespace();\n\t\tboolean nameChanged = !newName.equals(oldName);\n\t\tboolean scopeChanged = namespaceInOldProgram != oldNamespace;\n\t\tString tempName = null;\n\t\tif (nameChanged) {\n\t\t\ttry {\n\t\t\t\toldSymbol.setName(newName, source);","sourceCodeStart":2265,"sourceCodeEnd":2301,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/SymbolMerger.java#L2265-L2301","documentation":"Thrown as InvalidInputException by SymbolMerger.renameSymbol when DiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram) returns null — i.e. the namespace that contains the symbol in the new/result program has no matching namespace in the old program. The rename cannot proceed because the source-side namespace context is missing.","triggerScenarios":"Calling renameSymbol where the result program has a parent namespace that was never created (or was deleted) in the old program; the namespace lookup by DiffUtility found no equivalent namespace.","commonSituations":"Cross-program symbol sync where the target program is missing a namespace that exists in the source; merging after a namespace was removed on one side; stale symbol references to a namespace that no longer round-trips.","solutions":["Ensure the parent namespace exists in the old/target program before renaming — create it if missing.","Pre-sync namespaces between programs (DiffUtility.getNamespace should resolve) before performing symbol renames.","Catch InvalidInputException and skip/log the symbol rather than aborting the whole rename pass.","Verify the namespace path is equivalent (case, scope) across both programs."],"exampleFix":"// before\nNamespace ns = DiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram);\nif (ns == null) {\n    throw new InvalidInputException(\"Couldn't get namespace '...'.\");\n}\n\n// after — create the missing namespace first\nNamespace ns = DiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram);\nif (ns == null) {\n    ns = oldProgram.getSymbolTable().createNamespace(\n        newSymbol.getParentNamespace().getName(),\n        DiffUtility.getNamespace(newSymbol.getParentNamespace().getParentNamespace(), oldProgram),\n        SourceType.ANALYSIS);\n}","handlingStrategy":"validation","validationCode":"Namespace ns = DiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram);\nif (ns == null) {\n    // create the missing namespace before rename\n    ns = oldProgram.getSymbolTable().createNamespace(newSymbol.getParentNamespace().getName(),\n        DiffUtility.getNamespace(newSymbol.getParentNamespace().getParentNamespace(), oldProgram),\n        SourceType.ANALYSIS);\n}","typeGuard":"boolean nsResolves = DiffUtility.getNamespace(newSymbol.getParentNamespace(), oldProgram) != null;","tryCatchPattern":"try {\n    renameSymbol(oldProgram, oldSymbol, newProgram, newSymbol);\n} catch (InvalidInputException e) {\n    // skip symbols whose namespace is missing in old program\n}","preventionTips":["Sync namespaces between programs before symbol renames.","Verify namespace paths match (case/scope) across programs.","Create missing namespaces on demand rather than aborting."],"tags":["ghidra","merge","symbol","namespace","invalid-input"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}