{"record":{"id":"b21facc78b82df02","repo":"apache/maven","slug":"unable-to-parse-element-must-be-a-short-inte","errorCode":null,"errorMessage":"Unable to parse element '{}', must be a short integer","messagePattern":"Unable to parse element '(.+?)', must be a short integer","errorType":"exception","errorClass":"XMLStreamException","httpStatus":null,"severity":"error","filePath":"src/mdo/reader.vm","lineNumber":1022,"sourceCode":"    /**\n     * Method getShortValue.\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 short\n     */\n    private short getShortValue(String s, String attribute, XMLStreamReader parser, boolean strict)\n            throws XMLStreamException {\n        if (s != null) {\n            try {\n                return Short.valueOf(s).shortValue();\n            } catch (NumberFormatException nfe) {\n                if (strict) {\n                    throw new XMLStreamException(\"Unable to parse element '\" + attribute + \"', must be a short integer\", parser.getLocation(), nfe);\n                }\n            }\n        }\n        return 0;\n    } //-- short getShortValue(String, String, XMLStreamReader, boolean)\n\n    /**\n     * Method getTrimmedValue.\n     *\n     * @param s a s object.\n     * @return String\n     */\n    private String getTrimmedValue(String s) {\n        if (s != null) {\n            s = s.trim();\n        }\n        return s;\n    } //-- String getTrimmedValue(String)","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/src/mdo/reader.vm#L1004-L1040","documentation":"Thrown by the Modello-generated StAX reader (template src/mdo/reader.vm) when a model XML field typed as short cannot be parsed by Short.valueOf(String). getShortValue in strict mode converts the NumberFormatException into a javax.xml.stream.XMLStreamException ('must be a short integer'); non-strict mode returns 0. Only models that declare short fields can trigger it.","triggerScenarios":"Strict read of a model XML where a short field contains text like 'abc', is empty, or exceeds -32768..32767 (e.g. a port or count field set to 99999).","commonSituations":"Port/count fields overflowing after config changes; hand-edited files with typos; producers not validating ranges on write.","solutions":["Set the offending value within the short range (-32768..32767).","If the value legitimately exceeds short range, move to an int/long field in the model and regenerate the reader.","Use strict=false when defaulting to 0 is acceptable.","Validate config values with a schema or unit test before writing the file."],"exampleFix":"<!-- before -->\n<port>99999</port>\n<!-- after -->\n<port>32767</port>","handlingStrategy":"validation","validationCode":"static boolean inShortRange(int v) { return v >= Short.MIN_VALUE && v <= Short.MAX_VALUE; }","typeGuard":null,"tryCatchPattern":"try {\n    reader.read(in, true);\n} catch (XMLStreamException e) {\n    // message names field; fix data or downgrade to strict=false\n}","preventionTips":["Range-check config values before writing them to model files.","If ranges may grow, model the field as int from the start."],"tags":["xml","stax","modello","number-format","range-overflow"],"backgroundTag":"xml-numeric-field-parse-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}