{"record":{"id":"049e64f45906e06d","repo":"alibaba/spring-ai-alibaba","slug":"configuration-cannot-be-null","errorCode":null,"errorMessage":"Configuration cannot be null","messagePattern":"Configuration cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/strategy/FlowGraphBuildingStrategy.java","lineNumber":68,"sourceCode":"\t */\n\tStateGraph buildGraph(FlowGraphBuilder.FlowGraphConfig config) throws GraphStateException;\n\n\t/**\n\t * Returns the type identifier for this strategy. This is used for registration and\n\t * lookup purposes.\n\t * @return the strategy type identifier\n\t */\n\tString getStrategyType();\n\n\t/**\n\t * Validates that the configuration contains all required parameters for this\n\t * strategy.\n\t * @param config the configuration to validate\n\t * @throws IllegalArgumentException if validation fails\n\t */\n\tdefault void validateConfig(FlowGraphBuilder.FlowGraphConfig config) {\n\t\tif (config == null) {\n\t\t\tthrow new IllegalArgumentException(\"Configuration cannot be null\");\n\t\t}\n\t\tif (config.getName() == null || config.getName().trim().isEmpty()) {\n\t\t\tthrow new IllegalArgumentException(\"Graph name must be provided\");\n\t\t}\n\t\tif (config.getRootAgent() == null) {\n\t\t\tthrow new IllegalArgumentException(\"Root agent must be provided\");\n\t\t}\n\t\tif (config.getKeyStrategyFactory() == null) {\n\t\t\t// Generate a new KeyStrategyFactory based on agent keys\n\t\t\tKeyStrategyFactory generatedFactory = generateKeyStrategyFactory(config);\n\t\t\tconfig.keyStrategyFactory(generatedFactory);\n\t\t}\n\t}\n\n\t/**\n\t * Generates a KeyStrategyFactory based on the root agent and sub-agents.\n\t * @param config the configuration containing agents\n\t * @return the generated KeyStrategyFactory","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/flow/strategy/FlowGraphBuildingStrategy.java#L50-L86","documentation":"FlowGraphBuildingStrategy.validateConfig is a default interface guard that rejects a null FlowGraphConfig before any graph building work begins. It fails fast with IllegalArgumentException rather than a confusing NPE deeper in the builder.","triggerScenarios":"Calling buildGraph(null) or FlowGraphBuilder.build() with a config field never initialized (e.g. builder methods not invoked).","commonSituations":"Programmatic construction where the config object creation was skipped or a null was passed through a helper; mocking in tests returning null.","solutions":["Construct a FlowGraphConfig via FlowGraphBuilder before calling buildGraph","Check your wrapper/helper code for a path that forwards null","In tests, assert the builder produces a non-null config"],"exampleFix":"// before\nstrategy.buildGraph(null);\n// after\nFlowGraphBuilder.FlowGraphConfig config = FlowGraphBuilder.builder()\n    .name(\"my-flow\").rootAgent(root).buildConfig();\nstrategy.buildGraph(config);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(config, \"FlowGraphConfig must not be null\");","typeGuard":"static FlowGraphConfig requireConfig(FlowGraphBuilder.FlowGraphConfig c) { return java.util.Objects.requireNonNull(c, \"config\"); }","tryCatchPattern":"try { return strategy.buildGraph(config); } catch (IllegalArgumentException e) { throw new FlowBuildException(e.getMessage(), e); }","preventionTips":["Never pass raw null configs through helper methods","Use the FlowGraphBuilder fluent API rather than manual config construction","Enable null-analysis/annotations in your build"],"tags":["null-check","graph-builder","validation"],"backgroundTag":"null-argument","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}