{"record":{"id":"db0508049d00df65","repo":"OpenAPITools/openapi-generator","slug":"empty-method-name-operationid-not-allowed-db0508","errorCode":null,"errorMessage":"Empty method name (operationId) not allowed","messagePattern":"Empty method name \\(operationId\\) not allowed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java","lineNumber":325,"sourceCode":"            this.supportMultipleResponses = convertPropertyToBooleanAndWriteBack(SUPPORT_MULTIPLE_RESPONSES);\n        } else {\n            additionalProperties.put(this.SUPPORT_MULTIPLE_RESPONSES, this.supportMultipleResponses);\n        }\n\n        if (additionalProperties.containsKey(EXTRACT_ENUMS_TO_SEPARATE_FILES)) {\n            this.extractEnumsToSeparateFiles = convertPropertyToBooleanAndWriteBack(EXTRACT_ENUMS_TO_SEPARATE_FILES);\n        } else {\n            additionalProperties.put(EXTRACT_ENUMS_TO_SEPARATE_FILES, this.extractEnumsToSeparateFiles);\n        }\n\n        supportingFiles.add(new SupportingFile(\"README.mustache\", \"\", \"README.md\"));\n    }\n\n    @Override\n    public String toOperationId(String operationId) {\n        // throw exception if method name is empty (should not occur as an auto-generated method name will be used)\n        if (StringUtils.isEmpty(operationId)) {\n            throw new RuntimeException(\"Empty method name (operationId) not allowed\");\n        }\n\n        // method name cannot use reserved keyword, e.g. return\n        if (isReservedWord(operationId)) {\n            LOGGER.warn(\"{} (reserved word) cannot be used as method name. Renamed to {}\", operationId, camelize(sanitizeName(\"call_\" + operationId)));\n            operationId = \"call_\" + operationId;\n        }\n\n        return camelize(sanitizeName(operationId));\n    }\n\n    /**\n     * Creates an array schema from the provided object schema.\n     *\n     *  @param objectSchema the schema of the object to be wrapped in an array schema\n     *  @return the created array schema\n     */\n    private Schema createArraySchema(Schema objectSchema) {","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L307-L343","documentation":"The Protobuf schema generator's toOperationId() rejects empty method names with a RuntimeException (ProtobufSchemaCodegen.java:325). As its comment states, an auto-generated name is normally supplied when the spec omits operationId, so the throw points to an explicitly empty operationId value (or direct programmatic invocation). Reserved-word operationIds are handled by warning and renaming to call_<name>, not by throwing.","triggerScenarios":"Generating protobuf schema (`-g protobuf-schema`) from a spec containing `operationId: \"\"` (or whitespace-only) on an operation; or calling ProtobufSchemaCodegen.toOperationId(\"\") directly.","commonSituations":"Specs produced by converters that emit empty operationId keys; hand-edited files where the field was blanked; template-based spec generation with unfilled operationId placeholders.","solutions":["Fill in a unique non-empty operationId for each operation.","Remove the empty `operationId:` field so the generator's automatic path+method naming applies.","Add a CI spec-lint step that fails on empty operationId values."],"exampleFix":"# before (api.yaml)\npaths:\n  /items:\n    post:\n      operationId: \"\"\n      responses: { '201': { description: created } }\n# after\npaths:\n  /items:\n    post:\n      operationId: createItem\n      responses: { '201': { description: created } }","handlingStrategy":"validation","validationCode":"// protobuf-schema: same guard — empty-string operationIds throw, absent ones are synthesized\nopenAPI.getPaths().forEach((path, item) -> {\n  for (Operation op : item.readOperations().values()) {\n    if (op.getOperationId() != null && op.getOperationId().trim().isEmpty()) {\n      throw new IllegalArgumentException(\"Empty operationId on \" + path\n          + \" — set a value or remove the key\");\n    }\n  }\n});","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    throw new BuildException(\"Protobuf schema generation failed: \" + e.getMessage(), e);\n}","preventionTips":["Require non-empty unique operationIds for every operation in spec style guides.","Catch blank operationIds in CI spec linting before codegen stages run.","When templating specs, fail the template render if operationId placeholders are unfilled."],"tags":["protobuf","operation-id","openapi-spec","openapi-generator","spec-validation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}