{"record":{"id":"d199da1d0debabcb","repo":"alibaba/COLA","slug":"bizscenario-can-not-be-null-for-extension","errorCode":null,"errorMessage":"BizScenario can not be null for extension","messagePattern":"BizScenario can not be null for extension","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/ExtensionExecutor.java","lineNumber":118,"sourceCode":"    /**\n     * third try with default use case + default scenario\n     * <p>\n     * example:  biz1.#defaultUseCase#.#defaultScenario#\n     */\n    private <Ext> Ext defaultUseCaseTry(Class<Ext> targetClz, BizScenario bizScenario) {\n        logger.debug(\"Third trying with \" + bizScenario.getIdentityWithDefaultUseCase());\n        return locate(targetClz.getName(), bizScenario.getIdentityWithDefaultUseCase());\n    }\n\n    private <Ext> Ext locate(String name, String uniqueIdentity) {\n        final Ext ext = (Ext) extensionRepository.getExtensionRepo().\n                get(new ExtensionCoordinate(name, uniqueIdentity));\n        return ext;\n    }\n\n    private void checkNull(BizScenario bizScenario) {\n        if (bizScenario == null) {\n            throw new IllegalArgumentException(\"BizScenario can not be null for extension\");\n        }\n    }\n\n}\n","sourceCodeStart":100,"sourceCodeEnd":123,"githubUrl":"https://github.com/alibaba/COLA/blob/352e1a867538d9cd40e1b11e4028fa652fc97557/cola-components/cola-component-extension-starter/src/main/java/com/alibaba/cola/extension/ExtensionExecutor.java#L100-L123","documentation":"ExtensionExecutor.checkNull validates that the BizScenario argument supplied to extension lookups is non-null before resolving the extension point. If null, it throws a plain IllegalArgumentException with 'BizScenario can not be null for extension'. This is a programmer-error guard: the extension mechanism cannot route behavior without a business identity.","triggerScenarios":"Calling any ExtensionExecutor method (execute, responseCode, keyOf, locateExtension path) passing null for the BizScenario parameter, e.g. when the BizScenario was computed from a null request field or not initialized.","commonSituations":"A request DTO's bizId/useCase/scenario fields were not populated, so BizScenario.valueOf received nulls or the variable was never assigned; forgetting to derive BizScenario from context in generic/reusable service code.","solutions":["Construct and pass a valid BizScenario (use BizScenario.valueOf(bizId, useCase, scenario)) before calling ExtensionExecutor.","Validate the request fields feeding BizScenario.valueOf at the API boundary.","Default to BizScenario.DEFAULT when no specific identity applies.","Catch IllegalArgumentException if calling third-party code that may pass null, and surface a clear validation message."],"exampleFix":"// before\nextensionExecutor.execute(ExtPt.class, bizCode, ...);  // bizCode is null\n// after\nBizScenario scenario = BizScenario.valueOf(\n    Optional.ofNullable(bizCode).orElse(\"defaultBiz\"),\n    Optional.ofNullable(useCase).orElse(\"defaultUseCase\"),\n    Optional.ofNullable(scenario_).orElse(\"defaultScenario\"));\nextensionExecutor.execute(ExtPt.class, scenario, ...);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(bizScenario, \"BizScenario is required for extension execution\");","typeGuard":"static BizScenario requireScenario(BizScenario s) { return java.util.Objects.requireNonNull(s, \"BizScenario can not be null for extension\"); }","tryCatchPattern":"try { return extensionExecutor.execute(ExtPt.class, bizScenario, ...); } catch (IllegalArgumentException e) { log.error(\"Missing BizScenario: {}\", e.getMessage()); return badRequest(); }","preventionTips":["Always construct BizScenario via valueOf with non-null, validated inputs","Use BizScenario.DEFAULT when no identity applies","Validate biz/useCase/scenario request fields at the boundary","Never pass a BizScenario variable that is assigned conditionally without a default"],"tags":["java","cola","null-argument","bizscenario","illegal-argument"],"backgroundTag":"null-argument","analyzedSha":"352e1a867538d9cd40e1b11e4028fa652fc97557","analyzedAt":"2026-09-08T00:46:23.972Z","contentChangedAt":"2026-09-08T00:46:23.972Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}