{"record":{"id":"f13630eac0fa9051","repo":"OpenAPITools/openapi-generator","slug":"framework-is-required","errorCode":null,"errorMessage":"Framework is required","messagePattern":"Framework is required","errorType":"http","errorClass":"ResponseStatusException","httpStatus":400,"severity":"error","filePath":"modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/GenApiService.java","lineNumber":165,"sourceCode":"        } else {\n            return ResponseEntity.notFound().build();\n        }\n    }\n\n    @Override\n    public ResponseEntity<List<String>> clientOptions() {\n        return ResponseEntity.ok().body(clients);\n    }\n\n    @Override\n    public ResponseEntity<List<String>> serverOptions() {\n        return ResponseEntity.ok().body(servers);\n    }\n\n    @Override\n    public ResponseEntity<ResponseCode> generateServerForLanguage(String framework, GeneratorInput generatorInput) {\n        if (framework == null) {\n            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, \"Framework is required\");\n        }\n        String filename = Generator.generateServer(framework, generatorInput);\n        LOGGER.debug(\"generated name: {}\", filename);\n\n        return getResponse(filename, framework + \"-server\");\n    }\n\n    private ResponseEntity<ResponseCode> getResponse(String filename, String friendlyName) {\n        String host = System.getenv(\"GENERATOR_HOST\");\n\n        UriComponentsBuilder uriBuilder;\n        if (!StringUtils.isBlank(host)) {\n            uriBuilder = UriComponentsBuilder.fromUriString(host);\n        } else {\n            uriBuilder = ServletUriComponentsBuilder.fromCurrentContextPath();\n        }\n\n        if (filename != null) {","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/GenApiService.java#L147-L183","documentation":"Thrown by POST /api/gen/servers/{framework} (generateServerForLanguage, GenApiService.java:163-166) when the framework argument is null. Because framework arrives as a Spring path variable it is practically never null over HTTP (a missing segment simply does not route here), so this 400 guard fires mainly on direct/programmatic calls to the delegate or GenApiService, e.g. unit tests or custom controllers that pass a null reference.","triggerScenarios":"Calling genApiService.generateServerForLanguage(null, input) directly in code or tests; a custom wrapper/controller that resolves the framework from a query param or map lookup that returned null; reflection-based invocation without the argument.","commonSituations":"Writing integration tests against the delegate and forgetting to set the framework; wrapper services that look up framework from configuration (missing config key yields null); code ported from the clients endpoint where language was validated elsewhere.","solutions":["Always pass a concrete framework value (e.g. 'spring', 'nodejs-server'); pick from GET /api/gen/servers","If resolving the name dynamically, fail fast on null before calling the API (log which config key is missing)","In tests, use a known-good framework from the servers list instead of a placeholder"],"exampleFix":"// before\ndelegate.generateServerForLanguage(null, input);   // 400 Framework is required\n\n// after\nif (framework == null || framework.isBlank()) throw new IllegalArgumentException(\"framework not configured\");\ndelegate.generateServerForLanguage(framework, input);","handlingStrategy":"validation","validationCode":"// resolve and assert the framework before calling\nString framework = config.get(\"serverFramework\");\nif (framework == null || framework.isBlank()) {\n    throw new IllegalArgumentException(\"serverFramework missing in config; pick from GET /api/gen/servers\");\n}","typeGuard":"private static final Set<String> SERVERS = Set.copyOf(fetch(\"/api/gen/servers\"));\n\nboolean isSupportedFramework(String f) {\n    return f != null && SERVERS.contains(f);\n}","tryCatchPattern":null,"preventionTips":["Fetch GET /api/gen/servers and drive the UI/config from that list","Fail fast on null/blank names instead of forwarding them to the API"],"tags":["http-400","missing-parameter","spring-delegate","openapi-generator-online"],"backgroundTag":"missing-required-parameter","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}