{"record":{"id":"ec23af47db91117c","repo":"apache/maven","slug":"unable-to-parse-element-must-be-a-long-integ","errorCode":null,"errorMessage":"Unable to parse element '{}', must be a long integer","messagePattern":"Unable to parse element '(.+?)', must be a long integer","errorType":"exception","errorClass":"XMLStreamException","httpStatus":null,"severity":"error","filePath":"src/mdo/reader.vm","lineNumber":976,"sourceCode":"    /**\n     * Method getLongValue.\n     *\n     * @param s a s object.\n     * @param strict a strict object.\n     * @param parser a parser object.\n     * @param attribute a attribute object.\n     * @throws XMLStreamException XMLStreamException if\n     * any.\n     * @return long\n     */\n    private long getLongValue(String s, String attribute, XMLStreamReader parser, boolean strict)\n            throws XMLStreamException {\n        if (s != null) {\n            try {\n                return Long.valueOf(s).longValue();\n            } catch (NumberFormatException nfe) {\n                if (strict) {\n                    throw new XMLStreamException(\"Unable to parse element '\" + attribute + \"', must be a long integer\", parser.getLocation(), nfe);\n                }\n            }\n        }\n        return 0;\n    } //-- long getLongValue(String, String, XMLStreamReader, boolean)\n\n    /**\n     * Method getRequiredAttributeValue.\n     *\n     * @param s a s object.\n     * @param strict a strict object.\n     * @param parser a parser object.\n     * @param attribute a attribute object.\n     * @throws XMLStreamException XMLStreamException if\n     * any.\n     * @return String\n     */\n    private String getRequiredAttributeValue(String s, String attribute, XMLStreamReader parser, boolean strict)","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/src/mdo/reader.vm#L958-L994","documentation":"Thrown by the Modello-generated StAX reader (template src/mdo/reader.vm) when a model XML field typed as long cannot be parsed by Long.valueOf(String). getLongValue in strict mode wraps the NumberFormatException in a javax.xml.stream.XMLStreamException ('must be a long integer'); non-strict mode returns 0L. Commonly hit on timestamp/size fields expressed in nanoseconds or epoch millis.","triggerScenarios":"Strict read of a model XML where a long field holds an empty string, a decimal like '1690000000000.5', a value with unit suffix '1024b', or digits with grouping commas.","commonSituations":"Hand-tuned metadata or config files with human-friendly but unparseable numbers; copy-paste of values from spreadsheets that insert thin spaces/commas; schema changes between model versions.","solutions":["Fix the text at the reported location to a plain integer within long range.","Remove grouping separators and unit suffixes from generated files.","Re-fetch derived files instead of editing them.","Fall back to strict=false when the 0 default is acceptable."],"exampleFix":"<!-- before -->\n<size>1,048,576</size>\n<!-- after -->\n<size>1048576</size>","handlingStrategy":"validation","validationCode":"static boolean isPlainLong(String s) { return s != null && s.matches(\"[+-]?\\\\d+\") && s.length() < 19; }","typeGuard":null,"tryCatchPattern":"try {\n    reader.read(in, true);\n} catch (XMLStreamException e) {\n    log.warn(\"bad long field at \" + e.getLocation(), e);\n}","preventionTips":["Strip grouping separators when importing values from spreadsheets.","Store quantities without units in XML; interpret units in code."],"tags":["xml","stax","modello","number-format"],"backgroundTag":"xml-numeric-field-parse-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}