OpenAPITools/openapi-generator · error · RuntimeException

Empty method name (operationId) not allowed

Error message

Empty method name (operationId) not allowed

What it means

The scalaz (beta, http4s-based) client generator overrides toOperationId() identically to the Lagom generator: an empty or null operationId throws RuntimeException('Empty method name (operationId) not allowed'). openapi-generator usually synthesizes an id from method+path, so this fires on explicitly empty values passed through the spec.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java:214

    public CodegenType getTag() {
        return CodegenType.CLIENT;
    }

    @Override
    public String getName() {
        return "scalaz";
    }

    @Override
    public String getHelp() {
        return "Generates a Scalaz client library (beta) that uses http4s";
    }

    @Override
    public String toOperationId(String operationId) {
        // throw exception if method name is empty
        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)) {
            throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
        }

        return camelize(operationId, LOWERCASE_FIRST_LETTER);
    }

    private static abstract class CustomLambda implements Mustache.Lambda {
        @Override
        public void execute(Template.Fragment frag, Writer out) throws IOException {
            final StringWriter tempWriter = new StringWriter();
            frag.execute(tempWriter);
            out.write(formatFragment(tempWriter.toString()));
        }

View on GitHub (pinned to fcec517be3)

Solutions

  1. Set a meaningful non-empty operationId on every operation
  2. Delete the empty operationId key so the generator derives one from the path and method
  3. Validate the spec (Spectral operation-operationId or a pre-flight script) before invoking generation in CI

Example fix

# before
paths:
  /users/{id}:
    get:
      operationId: ''
# after
paths:
  /users/{id}:
    get:
      operationId: getUser
Defensive patterns

Strategy: validation

Validate before calling

# Lint every operation for a non-empty operationId (Python):
for path, item in spec['paths'].items():
    for method, op in item.items():
        if method in {'get','put','post','delete','options','head','patch','trace'}:
            oid = op.get('operationId')
            assert oid and oid.strip(), f'{method.upper()} {path} has an empty operationId'

Try / catch

try {
    new DefaultGenerator().opts(input).generate();
} catch (RuntimeException e) {
    // 'Empty method name (operationId) not allowed' - set or delete the operationId, then regenerate
}

Prevention

When it happens

Trigger: -g scalaz with a spec whose operation has operationId: '' or a null/blank value that reaches the generator unmodified.

Common situations: Machine-generated specs that emit an empty operationId key instead of omitting it; spec transformations that strip ids for deduplication then fail to refill them; legacy pipelines still using the beta scalaz generator.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/8e69ae9bfa232cda. Report an issue: GitHub.