{"record":{"id":"7db8c20f312f24cd","repo":"hibernate/hibernate-orm","slug":"passed-component-for-function-return-cannot-be-n","errorCode":null,"errorMessage":"Passed `component` for function return cannot be null","messagePattern":"Passed `component` for function return cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/internal/SetReturningFunctionTypeResolverBuilder.java","lineNumber":82,"sourceCode":"\t\t\tthrow new IllegalArgumentException( \"Passed `invariantType` for function return cannot be null\" );\n\t\t}\n\t\tif ( selectionExpression == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Passed `selectionExpression` for function return cannot be null\" );\n\t\t}\n\t\treturn withComponent( component, new BasicTypeTypeResolver( component, selectionExpression, invariantType ) );\n\t}\n\n\t@Override\n\tpublic SetReturningFunctionTypeResolverBuilder useArgType(String component, int argPosition, String selectionExpression) {\n\t\tif ( selectionExpression == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Passed `selectionExpression` for function return cannot be null\" );\n\t\t}\n\t\treturn withComponent( component, new ArgTypeTypeResolver( component, selectionExpression, argPosition ) );\n\t}\n\n\tprivate SetReturningFunctionTypeResolverBuilder withComponent(String component, TypeResolver resolver) {\n\t\tif ( component == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Passed `component` for function return cannot be null\" );\n\t\t}\n\t\ttypeResolvers.put( component, resolver );\n\t\treturn this;\n\t}\n\n\t@Override\n\tpublic SetReturningFunctionTypeResolver build() {\n\t\treturn new SetReturningFunctionTypeResolverImpl( this );\n\t}\n\n\tprivate static class SetReturningFunctionTypeResolverImpl implements SetReturningFunctionTypeResolver {\n\n\t\tprivate final TypeResolver[] typeResolvers;\n\n\t\tpublic SetReturningFunctionTypeResolverImpl(SetReturningFunctionTypeResolverBuilder builder) {\n\t\t\tthis.typeResolvers = builder.typeResolvers.values().toArray( new TypeResolver[0] );\n\t\t}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/internal/SetReturningFunctionTypeResolverBuilder.java#L64-L100","documentation":"withComponent(component, resolver) is the funnel every invariant()/useArgType() call on SetReturningFunctionTypeResolverBuilder passes through; it keys the resolver map by component name and rejects a null component with IllegalArgumentException. Any builder call whose first argument is null therefore fails at registration time, before the function is ever executed.","triggerScenarios":"builder.invariant(null, StandardBasicTypes.STRING, \"value\") or a computed component name that is null - e.g. derived from a map key, enum name, or config value that was absent.","commonSituations":"Component names generated from configuration or from reflection over array element types; a typo'd getter returning null; copy-pasted builder chains where the component variable is never assigned.","solutions":["Pass a stable, non-null component name - it identifies the row component of the set-returning function.","If the name comes from configuration, validate it early: Objects.requireNonNull(name, \"component\").","Also reject empty/blank names; they are technically accepted but produce confusing result mappings."],"exampleFix":"// before\nString name = config.get(\"component\"); // null\nbuilder.invariant(name, StandardBasicTypes.STRING, name);\n\n// after\nString name = Objects.requireNonNull(config.get(\"component\"), \"component\");\nbuilder.invariant(name, StandardBasicTypes.STRING, name);","handlingStrategy":"validation","validationCode":"String component = Objects.requireNonNull(componentName, \"component\");\nif (component.isBlank()) throw new IllegalArgumentException(\"component must not be blank\");\nbuilder.invariant(component, type, selectionExpression);","typeGuard":null,"tryCatchPattern":"try {\n    builder.invariant(component, type, selection);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Incomplete set-returning function definition: \" + e.getMessage(), e);\n}","preventionTips":["Treat component names as required identifiers, not optional labels.","Validate config- or reflection-derived names before the builder call.","Boot-test all set-returning function registrations."],"tags":["hibernate","set-returning-function","null-check","function-registration","bootstrap"],"backgroundTag":"illegal-argument-null-parameter","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}