{"record":{"id":"6cbb9f2cbf32b4c2","repo":"nathanmarz/storm","slug":"fields-order-must-be-same-length-as-pointers-map","errorCode":null,"errorMessage":"Fields order must be same length as pointers map","messagePattern":"Fields order must be same length as pointers map","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/storm/trident/tuple/ValuePointer.java","lineNumber":37,"sourceCode":"\nimport backtype.storm.tuple.Fields;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport org.apache.commons.lang.builder.ToStringBuilder;\n\npublic class ValuePointer {\n    public static Map<String, ValuePointer> buildFieldIndex(ValuePointer[] pointers) {\n        Map<String, ValuePointer> ret = new HashMap<String, ValuePointer>();\n        for(ValuePointer ptr: pointers) {\n            ret.put(ptr.field, ptr);\n        }\n        return ret;        \n    }\n\n    public static ValuePointer[] buildIndex(Fields fieldsOrder, Map<String, ValuePointer> pointers) {\n        if(fieldsOrder.size()!=pointers.size()) {\n            throw new IllegalArgumentException(\"Fields order must be same length as pointers map\");\n        }\n        ValuePointer[] ret = new ValuePointer[pointers.size()];\n        List<String> flist = fieldsOrder.toList();\n        for(int i=0; i<fieldsOrder.size(); i++) {\n            ret[i] = pointers.get(fieldsOrder.get(i));\n        }\n        return ret;\n    }    \n    \n    public int delegateIndex;\n    protected int index;\n    protected String field;\n    \n    public ValuePointer(int delegateIndex, int index, String field) {\n        this.delegateIndex = delegateIndex;\n        this.index = index;\n        this.field = field;\n    }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/storm/trident/tuple/ValuePointer.java#L19-L55","documentation":"ValuePointer.buildIndex builds a positional index mapping field names to tuple value locations. It requires the ordered Fields list and the pointer map to describe exactly the same field set; a size mismatch means the two views disagree, so it throws IllegalArgumentException.","triggerScenarios":"Internal Trident wiring where the Fields order passed (e.g. from a projection/each) contains a different number of fields than the ValuePointer map built from the upstream output — usually triggered by a user-supplied Fields selector that doesn't match declared output fields.","commonSituations":"Selecting fields in an each/project that don't exist or number differently from the function's declared fields; merging streams whose declarations diverged.","solutions":["Verify the Fields argument matches exactly the declared output fields of the preceding operation","Use TridentUtils/fields validation or print stream.getOutputFields() to compare before wiring","Fix upstream function declarations so the number of emitted values equals declared fields"],"exampleFix":"// before\nstream.each(new Fields(\"a\", \"b\", \"c\"), new MyFunc(), new Fields(\"out\"))\n// after  (upstream only declares a, b)\nstream.each(new Fields(\"a\", \"b\"), new MyFunc(), new Fields(\"out\"))","handlingStrategy":"validation","validationCode":"if (fieldsOrder.size() != pointers.size()) {\n  throw new IllegalArgumentException(\"fieldsOrder and pointers must describe the same fields\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  ValuePointer[] idx = ValuePointer.buildIndex(fieldsOrder, pointers);\n} catch (IllegalArgumentException e) {\n  LOG.error(\"Field selector does not match declared output fields\", e);\n}","preventionTips":["Match Fields selectors exactly to the upstream operation's declared output fields","Log getOutputFields() during topology debugging","Keep function emit-value counts equal to declared field counts"],"tags":["storm","trident","fields","validation"],"backgroundTag":"shape-mismatch","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}