{"record":{"id":"0573e7b891157fe1","repo":"nathanmarz/storm","slug":"additive-operations-cannot-add-fields-with-same-name-as","errorCode":null,"errorMessage":"Additive operations cannot add fields with same name as already exists. Tried adding ","messagePattern":"Additive operations cannot add fields with same name as already exists\\. Tried adding ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/storm/trident/tuple/TridentTupleView.java","lineNumber":127,"sourceCode":"    public static class OperationOutputFactory implements Factory {\n        Map<String, ValuePointer> _fieldIndex;\n        ValuePointer[] _index;\n        Factory _parent;\n\n        public OperationOutputFactory(Factory parent, Fields selfFields) {\n            _parent = parent;\n            _fieldIndex = new HashMap(parent.getFieldIndex());\n            int myIndex = parent.numDelegates();\n            for(int i=0; i<selfFields.size(); i++) {\n                String field = selfFields.get(i);\n                _fieldIndex.put(field, new ValuePointer(myIndex, i, field));\n            }\n            List<String> myOrder = new ArrayList<String>(parent.getOutputFields());\n            \n            Set<String> parentFieldsSet = new HashSet<String>(myOrder);\n            for(String f: selfFields) {\n                if(parentFieldsSet.contains(f)) {\n                    throw new IllegalArgumentException(\n                            \"Additive operations cannot add fields with same name as already exists. \"\n                            + \"Tried adding \" + selfFields + \" to \" + parent.getOutputFields());\n                }\n                myOrder.add(f);\n            }\n            \n            _index = ValuePointer.buildIndex(new Fields(myOrder), _fieldIndex);\n        }\n        \n        public TridentTuple create(TridentTupleView parent, List<Object> selfVals) {\n            IPersistentVector curr = parent._delegates;\n            curr = (IPersistentVector) RT.conj(curr, selfVals);\n            return new TridentTupleView(curr, _index, _fieldIndex);\n        }\n\n        @Override\n        public Map<String, ValuePointer> getFieldIndex() {\n            return _fieldIndex;","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/storm/trident/tuple/TridentTupleView.java#L109-L145","documentation":"Trident's additive operations (each/newValues) produce a new tuple view whose fields are parent fields plus new fields. Duplicate names between the parent's output fields and the operation's added fields would create ambiguity, so OperationOutputFactory throws IllegalArgumentException.","triggerScenarios":"An each() (or similar additive operation) declares output fields that already exist on the incoming stream, e.g. .each(new Fields(\"x\"), new IdentityFunction(), new Fields(\"x\")) without renaming.","commonSituations":"Copy-pasted function wiring reusing the same field name; functions that output the same name as their input; stream merges bringing duplicate field names into one topology node.","solutions":["Rename the newly added fields, e.g. new Fields(\"x_copy\"), or use each with a different output name","Use a projection (new Fields(...)) to drop conflicting parent fields before the operation","Ensure custom Functions emit distinct output field names"],"exampleFix":"// before\nstream.each(new Fields(\"url\"), new Parse(), new Fields(\"url\"))\n// after\nstream.each(new Fields(\"url\"), new Parse(), new Fields(\"parsedUrl\"))","handlingStrategy":"validation","validationCode":"Set<String> parent = new HashSet<>(stream.getOutputFields());\nfor (String f : newFields) {\n  if (parent.contains(f)) throw new IllegalArgumentException(\"Field \" + f + \" already exists on stream\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  stream.each(inputFields, func, outputFields);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Additive operations cannot add fields\")) {\n    LOG.error(\"Duplicate output field: rename the added fields\", e);\n  }\n  throw e;\n}","preventionTips":["Name operation outputs distinctly from input fields (e.g. prefixed)","Check stream.getOutputFields() before wiring each()","Avoid merging streams with overlapping field names without projection"],"tags":["storm","trident","fields","validation"],"backgroundTag":"conflicting-config-options","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"}