{"record":{"id":"273eccab680f7f36","repo":"oracle/graal","slug":"unexpected-end-document-header","errorCode":null,"errorMessage":"Unexpected end document header","messagePattern":"Unexpected end document header","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java","lineNumber":566,"sourceCode":"            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        }\n        documentLevelProperties = newProperties;\n        newProperties = null;\n    }\n\n    private GraphDocument resolveDocument(Properties props, Group g) {\n        if (rootDocument != null) {\n            return rootDocument;\n        }\n        rootDocument = rootDocumentFactory.documentFor(documentId, props, g);\n\n        if (rootDocument == null) {\n            throw new IllegalStateException(\"Could not find a parent for group \" + folder);\n        }\n        rootDocumentResolved(rootDocument);\n        return rootDocument;\n    }\n","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/ModelBuilder.java#L548-L584","documentation":"ModelBuilder pairs startDocumentHeader/endDocumentHeader; endDocumentHeader throws IllegalStateException('Unexpected end document header') when newProperties is null, i.e. end was called without a preceding successful start (or after the state was already consumed). At the parse level this reflects a malformed stream where a document-property section terminates without being opened, or nested/duplicated header terminators.","triggerScenarios":"A stream whose document-properties section is misaligned so endDocumentHeader runs without startDocumentHeader having set newProperties; duplicated terminators from corrupted bytes; programmatic misuse of the ModelBuilder API by calling endDocumentHeader standalone.","commonSituations":"Damaged dump files; custom builders/tests driving ModelBuilder directly and mishandling the start/end pairing.","solutions":["If driving ModelBuilder programmatically, always bracket parseProperties with startDocumentHeader/endDocumentHeader.","For parse-time occurrences, regenerate the dump; treat as corruption.","Wrap header parsing in try/finally so an exception inside the header cannot leave the builder half-open."],"exampleFix":"// before\nbuilder.endDocumentHeader(); // called without start\n\n// after\nbuilder.startDocumentHeader();\ntry {\n    parseProperties();\n} finally {\n    builder.endDocumentHeader();\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"builder.startDocumentHeader();\ntry { parseProperties(); } finally { builder.endDocumentHeader(); }","preventionTips":["Always bracket document-header parsing with start/end in try-finally.","Never call endDocumentHeader without a successful startDocumentHeader.","Treat parse-time occurrences as malformed streams and regenerate the dump."],"tags":["graphio","model-builder","state-machine","corrupt-input"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}