{"record":{"id":"fd6d3e0c15a7f1ed","repo":"oracle/graal","slug":"document-header-not-at-root-level","errorCode":null,"errorMessage":"Document header not at root level.","messagePattern":"Document header not at root level\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java","lineNumber":549,"sourceCode":"        return g;\n    }\n\n    @Override\n    public Group startGroup() {\n        Group group = createGroup(folder);\n        return pushGroup(group, true);\n    }\n\n    protected void rootDocumentResolved(GraphDocument doc) {\n        this.rootDocument = doc;\n    }\n\n    @Override\n    public void startDocumentHeader() {\n        Folder f = getParent();\n        if (f != null) {\n            if (!(f instanceof GraphDocument)) {\n                throw new IllegalStateException(\"Document header not at root level.\");\n            }\n            newProperties = ((GraphDocument) f).getProperties();\n        } else {\n            // note: if there are more document headers in the stream,\n            // the last property value wins. All document-level property sets merge in the result.\n            if (rootDocument == null) {\n                newProperties = Properties.newProperties();\n            } else {\n                newProperties = rootDocument.getProperties();\n            }\n        }\n    }\n\n    @Override\n    public void endDocumentHeader() {\n        if (newProperties == null) {\n            throw new IllegalStateException(\"Unexpected end document header\");\n        }","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java#L531-L567","documentation":"ModelBuilder.startDocumentHeader implements the rule that document (stream) properties may only appear at the top level of a dump: the current parent folder must be the GraphDocument itself or null. If a STREAM_PROPERTIES entry is encountered while a group is open (parent is a Group), IllegalStateException('Document header not at root level.') is thrown, because a conforming writer never nests stream properties inside a group.","triggerScenarios":"A stream in which STREAM_PROPERTIES appears after BEGIN_GROUP but before CLOSE_GROUP; corrupted nesting that leaves a group open; custom writers emitting document properties at the wrong nesting point.","commonSituations":"Malformed or hand-assembled dumps; producer bugs that write document properties lazily after the first group has started; damaged files.","solutions":["Re-dump the file with a stock producer (document properties are written before any group in a conforming stream).","If writing a custom producer, emit STREAM_PROPERTIES only at the root, before any BEGIN_GROUP.","Treat the message as evidence of stream damage and verify integrity/versions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { reader.parse(); } catch (IllegalStateException e) { if (e.getMessage().contains(\"Document header not at root level\")) { /* malformed nesting: regenerate dump */ } }","preventionTips":["In custom writers, emit STREAM_PROPERTIES only at the stream root, before any BEGIN_GROUP.","Do not hand-assemble dump bodies.","Treat nesting violations as corruption and re-export."],"tags":["graphio","parsing","document-properties","corrupt-input"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}