OpenAPITools/openapi-generator · error · RuntimeException
Empty method name (operationId) not allowed
Error message
Empty method name (operationId) not allowed
What it means
AbstractPythonPydanticV1Codegen.toOperationId throws RuntimeException when the operationId it receives is empty; the code comment notes this should not occur because the default pipeline auto-generates a method name. Reaching the guard means id synthesis upstream did not happen or produced an empty string.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java:278
// obtain the name from parameterNameMapping directly if provided
if (parameterNameMapping.containsKey(name)) {
return parameterNameMapping.get(name);
}
// to avoid conflicts with 'callback' parameter for async call
if ("callback".equals(name)) {
return "param_callback";
}
// use variable-name normalization without model property mappings
return toVarNameWithoutNameMapping(name);
}
@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, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, underscore(sanitizeName("call_" + operationId)));
operationId = "call_" + operationId;
}
return underscore(sanitizeName(operationId));
}
@OverrideView on GitHub (pinned to fcec517be3)
Solutions
- Give every operation a unique non-empty operationId
- If relying on auto-generation, keep a summary containing at least some word characters so the synthesized id is non-empty
- Delete operationId: "" keys entirely so summary/path-based fallback naming applies
Example fix
# before get: operationId: '' summary: '***' # after get: operationId: list_users summary: List users
Defensive patterns
Strategy: validation
Validate before calling
// JS: flag empty operationIds, and summaries that sanitize to empty
for (const [p, item] of Object.entries(spec.paths || {})) {
for (const [m, op] of Object.entries(item)) {
if (!op || !op.responses) continue;
if (op.operationId === '' ) fail(`${m} ${p}: empty operationId`);
if (op.operationId === undefined && !(op.summary || '').match(/[a-z0-9]/i)) fail(`${m} ${p}: no usable summary for id synthesis`);
}
} Try / catch
try { generator.generate(); } catch (RuntimeException e) { if ("Empty method name (operationId) not allowed".equals(e.getMessage())) { /* set an operationId on the failing operation */ } throw e; } Prevention
- Give every operation an explicit operationId in authored specs
- When templating specs, fail the build on empty rendered ids
- Keep summaries with at least one word character so fallback naming works
When it happens
Trigger: An operation with operationId: "" (explicitly empty) whose summary is absent or sanitizes to empty (e.g. a summary of only punctuation/emoji), or a direct programmatic call to the generator API passing an empty operationId.
Common situations: Templated spec pipelines that render operationId from data which can be empty; conversion tools that blank ids; specs whose summaries are non-word characters only.
Related errors
- Error! Failed to process getPydanticType when getting the co
- Error! Codegen Parameter not yet supported in getPydanticTyp
- Error! Failed to process getPydanticType when getting the co
- Error! Codegen Parameter not yet supported in getPydanticTyp
- Empty method name (operationId) not allowed
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/da665030c0dadd11.
Report an issue: GitHub.