{"record":{"id":"a58e9a6a41950809","repo":"OpenAPITools/openapi-generator","slug":"empty-method-operation-name-operationid-not-allo-a58e9a","errorCode":null,"errorMessage":"Empty method/operation name (operationId) not allowed","messagePattern":"Empty method/operation name \\(operationId\\) not allowed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java","lineNumber":866,"sourceCode":"                    modelName);\n            return modelName;\n        }\n\n        schemaKeyToModelNameCache.put(name, titleCase(modifiedName));\n        return schemaKeyToModelNameCache.get(name);\n    }\n\n    /**\n     * Return the operation ID (method name)\n     *\n     * @param operationId operation ID\n     * @return the sanitized method name\n     */\n    @Override\n    public String toOperationId(String operationId) {\n        // throw exception if method name is empty\n        if (StringUtils.isEmpty(operationId))\n            throw new RuntimeException(\"Empty method/operation name (operationId) not allowed\");\n\n        operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);\n\n        // method name cannot use reserved keyword, e.g. return\n        if (isReservedWord(operationId)) {\n            String newOperationId = camelize(\"call_\" + operationId, LOWERCASE_FIRST_LETTER);\n            LOGGER.warn(\"{} (reserved word) cannot be used as method name. Renamed to {}\", operationId, newOperationId);\n            return newOperationId;\n        }\n\n        // operationId starts with a number\n        if (operationId.matches(\"^\\\\d.*\")) {\n            LOGGER.warn(operationId + \" (starting with a number) cannot be used as method name. Renamed to \" + camelize(\"call_\" + operationId), LOWERCASE_FIRST_LETTER);\n            operationId = camelize(\"call_\" + operationId, LOWERCASE_FIRST_LETTER);\n        }\n\n        return operationId;\n    }","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java#L848-L884","documentation":"AbstractKotlinCodegen.toOperationId throws when the operation name reaching it is null or empty. Kotlin function names in the generated client/server code come from operationId; an empty one would produce invalid Kotlin, so generation aborts. A path-derived default normally prevents this, so it indicates an explicit blank or a custom code path.","triggerScenarios":"A spec operation with 'operationId: \"\"' processed where default derivation is bypassed, or a custom Kotlin generator calling toOperationId directly with an empty id.","commonSituations":"Specs produced by converters that blank operationIds; hand-edited specs; generator subclasses that preprocess operation ids.","solutions":["Give every operation a unique non-empty operationId.","Remove the empty operationId key entirely so the default name is derived from path+method.","Ensure custom generator overrides never pass empty strings into toOperationId."],"exampleFix":"# before:\npaths:\n  /pets:\n    get:\n      operationId: ''\n# after:\npaths:\n  /pets:\n    get:\n      operationId: listPets","handlingStrategy":"validation","validationCode":"// Pre-flight: every operation must have a non-empty operationId\nOpenAPI api = new OpenAPIV3Parser().read(\"spec.yaml\");\napi.getPaths().forEach((path, item) -> item.readOperationsMap().forEach((method, op) -> {\n    String id = op.getOperationId();\n    if (id == null || id.trim().isEmpty())\n        throw new IllegalStateException(method + \" \" + path + \" has an empty operationId\");\n}));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Author explicit operationIds for every operation.","Never leave an empty-string operationId in the spec; omit the key instead.","Validate specs with a lint step before Kotlin generation."],"tags":["openapi","operationid","kotlin","code-generation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}