{"record":{"id":"392999799a24abc5","repo":"apache/seatunnel","slug":"index-index-fields-size-size","errorCode":null,"errorMessage":"Index: <index>, Fields size:<size>","messagePattern":"Index: <index>, Fields size:<size>","errorType":"exception","errorClass":"IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/rest/models/Schema.java","lineNumber":77,"sourceCode":"    }\n\n    public void put(\n            String name,\n            String type,\n            String comment,\n            int scale,\n            int precision,\n            String aggregationType) {\n        properties.add(new Field(name, type, comment, scale, precision, aggregationType));\n    }\n\n    public void put(Field f) {\n        properties.add(f);\n    }\n\n    public Field get(int index) {\n        if (index >= properties.size()) {\n            throw new IndexOutOfBoundsException(\n                    \"Index: \" + index + \", Fields size:\" + properties.size());\n        }\n        return properties.get(index);\n    }\n\n    public int size() {\n        return properties.size();\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) {\n            return true;\n        }\n        if (o == null || getClass() != o.getClass()) {\n            return false;\n        }\n        Schema schema = (Schema) o;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/rest/models/Schema.java#L59-L95","documentation":"Schema.get() is a custom accessor over an internal list of Field objects in the Doris REST table schema model. It throws IndexOutOfBoundsException when the requested index is >= the number of fields, deliberately including the size in the message since java.util.List.get's default message is less descriptive. It guards only the upper bound; a negative index will still be thrown by the underlying list.","triggerScenarios":"Calling Schema.get(i) with i >= schema.size() while walking the Doris FE /schema REST response, e.g. iterating with a stale or wrong field count, or parsing a schema whose fields were truncated by an FE misconfiguration.","commonSituations":"Parsing Doris table metadata during schema-based save-mode table creation; loop bounds mismatch after a concurrent ALTER TABLE changed the schema; off-by-one loops like `for (i = 0; i <= schema.size(); i++)`.","solutions":["Check the index against schema.size() before calling get(index)","Re-fetch the Doris table schema if it may have changed (ALTER TABLE) instead of caching it","Fix loop bounds (use `<` not `<=`) when iterating fields"],"exampleFix":"// before\nField f = schema.get(index);\n// after\nif (index < 0 || index >= schema.size()) {\n    throw new IllegalArgumentException(\"field index out of range: \" + index);\n}\nField f = schema.get(index);","handlingStrategy":"validation","validationCode":"if (schema == null || index < 0 || index >= schema.size()) return null;\nField f = schema.get(index);","typeGuard":"boolean inRange(int i, Schema s) { return s != null && i >= 0 && i < s.size(); }","tryCatchPattern":null,"preventionTips":["Always derive loop bounds from schema.size()","Refetch schema after any ALTER TABLE","Never cache field counts across schema changes"],"tags":["index-out-of-bounds","doris","schema-parsing"],"backgroundTag":"index-out-of-bounds","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}