OpenAPITools/openapi-generator · error · RuntimeException
Empty method name (operationId) not allowed
Error message
Empty method name (operationId) not allowed
What it means
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.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java:325
this.supportMultipleResponses = convertPropertyToBooleanAndWriteBack(SUPPORT_MULTIPLE_RESPONSES);
} else {
additionalProperties.put(this.SUPPORT_MULTIPLE_RESPONSES, this.supportMultipleResponses);
}
if (additionalProperties.containsKey(EXTRACT_ENUMS_TO_SEPARATE_FILES)) {
this.extractEnumsToSeparateFiles = convertPropertyToBooleanAndWriteBack(EXTRACT_ENUMS_TO_SEPARATE_FILES);
} else {
additionalProperties.put(EXTRACT_ENUMS_TO_SEPARATE_FILES, this.extractEnumsToSeparateFiles);
}
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty (should not occur as an auto-generated method name will be used)
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
return camelize(sanitizeName(operationId));
}
/**
* Creates an array schema from the provided object schema.
*
* @param objectSchema the schema of the object to be wrapped in an array schema
* @return the created array schema
*/
private Schema createArraySchema(Schema objectSchema) {View on GitHub (pinned to fcec517be3)
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.
Example fix
# before (api.yaml)
paths:
/items:
post:
operationId: ""
responses: { '201': { description: created } }
# after
paths:
/items:
post:
operationId: createItem
responses: { '201': { description: created } } Defensive patterns
Strategy: validation
Validate before calling
// protobuf-schema: same guard — empty-string operationIds throw, absent ones are synthesized
openAPI.getPaths().forEach((path, item) -> {
for (Operation op : item.readOperations().values()) {
if (op.getOperationId() != null && op.getOperationId().trim().isEmpty()) {
throw new IllegalArgumentException("Empty operationId on " + path
+ " — set a value or remove the key");
}
}
}); Try / catch
try {
new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
throw new BuildException("Protobuf schema generation failed: " + e.getMessage(), e);
} Prevention
- 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.
When it happens
Trigger: Generating protobuf schema (`-g protobuf-schema`) from a spec containing `operationId: ""` (or whitespace-only) on an operation; or calling ProtobufSchemaCodegen.toOperationId("") directly.
Common situations: 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.
Related errors
- Empty method name (operationId) not allowed
- Empty method name (operationId) not allowed
- The BLOB and JSON data types cannot be assigned a default va
- Empty database/table/column name for property '{name}' not a
- The BLOB, TEXT, GEOMETRY, and JSON data types cannot be assi
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/db0508049d00df65.
Report an issue: GitHub.