{"record":{"id":"9d4daa8b1e0bc0d6","repo":"apache/flink","slug":"pos-9d4daa","errorCode":null,"errorMessage":"{pos}","messagePattern":"\\{pos\\}","errorType":"exception","errorClass":"IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"flink-core-api/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java","lineNumber":121,"sourceCode":"\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public <T> T getField(int pos) {\n        switch (pos) {\n            case 0:\n                return (T) this.f0;\n            case 1:\n                return (T) this.f1;\n            case 2:\n                return (T) this.f2;\n            case 3:\n                return (T) this.f3;\n            case 4:\n                return (T) this.f4;\n            case 5:\n                return (T) this.f5;\n            default:\n                throw new IndexOutOfBoundsException(String.valueOf(pos));\n        }\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public <T> void setField(T value, int pos) {\n        switch (pos) {\n            case 0:\n                this.f0 = (T0) value;\n                break;\n            case 1:\n                this.f1 = (T1) value;\n                break;\n            case 2:\n                this.f2 = (T2) value;\n                break;\n            case 3:\n                this.f3 = (T3) value;","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core-api/src/main/java/org/apache/flink/api/java/tuple/Tuple6.java#L103-L139","documentation":"Tuple6.getField(int pos) throws IndexOutOfBoundsException when the requested field position is outside 0..5. Tuples are fixed-arity containers, so any position beyond the last field (f5) or a negative position is rejected. The message is simply the invalid position number.","triggerScenarios":"Calling tuple6.getField(6) or getField(-1); generic code that indexes fields with a value derived from getArity() of a different tuple class; passing a 1-based field index into this 0-based API (e.g. getField(6) intending the 'sixth' field).","commonSituations":"Code written against Tuple5/Tuple7 reused with Tuple6; field positions read from configuration or a projection list (Table/SQL select indices) applied to the wrong tuple arity; off-by-one loops such as `for (int i = 1; i <= tuple.getArity(); i++)`.","solutions":["Use 0-based indices: valid positions for Tuple6 are 0 through 5","Bounds-check before the call: `if (pos >= 0 && pos < tuple.getArity())`","If the index comes from a projection/config, validate it against Tuple.getArity() at parse time and fail with a clear message","Prefer accessing the typed fields directly (tuple.f0 .. tuple.f5) when the position is known at compile time"],"exampleFix":"// before\nObject v = tuple6.getField(6); // IndexOutOfBoundsException: 6\n\n// after\nObject v = (idx >= 0 && idx < tuple6.getArity())\n        ? tuple6.getField(idx)\n        : null; // or throw a descriptive exception","handlingStrategy":"validation","validationCode":"// before any positional read\nif (pos < 0 || pos >= tuple6.getArity()) {\n    throw new IllegalArgumentException(\"pos \" + pos + \" outside Tuple6 arity 6\");\n}\nObject v = tuple6.getField(pos);","typeGuard":null,"tryCatchPattern":"catch (IndexOutOfBoundsException e) { /* message is the bad pos; log schema/index source and rethrow with context */ }","preventionTips":["Always treat tuple field positions as 0-based","Loop with `for (int i = 0; i < tuple.getArity(); i++)`","Validate externally supplied indices against getArity() once at load time","Prefer typed field access (tuple.fN) when the position is known at compile time"],"tags":["tuple","index-out-of-bounds","flink-core-api","validation"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}