{"record":{"id":"9d9a423152255620","repo":"nathanmarz/storm","slug":"trying-to-select-non-existent-field-field-from-stream","errorCode":null,"errorMessage":"Trying to select non-existent field: '${field}' from stream containing fields fields: <${allFields}>","messagePattern":"Trying to select non-existent field: '(.+?)' from stream containing fields fields: <(.+?)>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/storm/trident/Stream.java","lineNumber":370,"sourceCode":"            return s.global();\n        }\n\n        @Override\n        public BatchToPartition singleEmitPartitioner() {\n            return new GlobalBatchToPartition();\n        }\n        \n    }\n\n    private void projectionValidation(Fields projFields) {\n        if (projFields == null) {\n            return;\n        }\n\n        Fields allFields = this.getOutputFields();\n        for (String field : projFields) {\n            if (!allFields.contains(field)) {\n                throw new IllegalArgumentException(\"Trying to select non-existent field: '\" + field + \"' from stream containing fields fields: <\" + allFields + \">\");\n            }\n        }\n    }\n}\n","sourceCodeStart":352,"sourceCodeEnd":375,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/storm/trident/Stream.java#L352-L375","documentation":"Trident validates at topology-build time that every field named in a projection actually exists on the stream's output schema. When a field in the projection list is not present in getOutputFields(), Stream.projectionValidation throws this IllegalArgumentException. It is an early fail-fast check so bad field names surface locally instead of as runtime tuple errors on workers.","triggerScenarios":"Calling stream.project(Fields), groupBy, partitionBy, each, partitionAggregate, or stateQuery with a Fields object naming a field not produced by the upstream stream's declared output fields.","commonSituations":"Typos in field names; an upstream function/aggregate whose declared output fields changed; copy-pasted pipeline code where a renamed field was not propagated; chaining operations assuming extra fields survive operations that only pass declared fields through.","solutions":["Fix the field name in the projection/operation call to match the upstream stream's output fields","Check what fields the stream actually declares (e.g. each(new Function, new Fields(\"a\",\"b\")) output) and print/inspect getOutputFields","Update the upstream operation's output Fields declaration so the field exists","Reorder the pipeline so the projection happens after the operation that produces the field"],"exampleFix":"// before\nstream.each(new Fields(\"userId\"), filter);\n// after (field is actually named \"user_id\")\nstream.each(new Fields(\"user_id\"), filter);","handlingStrategy":"validation","validationCode":"Fields out = stream.getOutputFields();\nfor (String f : projectionFields) {\n    if (!out.contains(f)) throw new IllegalStateException(\"Field '\" + f + \"' not in stream fields \" + out);\n}","typeGuard":"boolean isProjectedValidly(Fields out, Fields proj) {\n    return Arrays.stream(proj.toList()).allMatch(out::contains);\n}","tryCatchPattern":"try {\n    stream.project(fields);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Trying to select non-existent field\")) {\n        log.error(\"Field mismatch; stream fields=\" + stream.getOutputFields(), e);\n    } else throw e;\n}","preventionTips":["Inspect getOutputFields() before projecting","Keep output-field declarations next to each operation and update consumers when renaming","Write a unit test that builds the topology (topology.build()) to fail fast on field typos"],"tags":["storm","trident","fields-validation"],"backgroundTag":"schema-validation-failed","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"}