{"record":{"id":"83a706dd0a5ec4e5","repo":"OpenAPITools/openapi-generator","slug":"operationid-reserved-word-cannot-be-used-83a706","errorCode":null,"errorMessage":"\" + operationId + \" (reserved word) cannot be used as method name","messagePattern":"\" \\+ operationId \\+ \" \\(reserved word\\) cannot be used as method name","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java","lineNumber":219,"sourceCode":"    public String getName() {\n        return \"scalaz\";\n    }\n\n    @Override\n    public String getHelp() {\n        return \"Generates a Scalaz client library (beta) that uses http4s\";\n    }\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 name (operationId) not allowed\");\n        }\n\n        // method name cannot use reserved keyword, e.g. return\n        if (isReservedWord(operationId)) {\n            throw new RuntimeException(operationId + \" (reserved word) cannot be used as method name\");\n        }\n\n        return camelize(operationId, LOWERCASE_FIRST_LETTER);\n    }\n\n    private static abstract class CustomLambda implements Mustache.Lambda {\n        @Override\n        public void execute(Template.Fragment frag, Writer out) throws IOException {\n            final StringWriter tempWriter = new StringWriter();\n            frag.execute(tempWriter);\n            out.write(formatFragment(tempWriter.toString()));\n        }\n\n        public abstract String formatFragment(String fragment);\n    }\n\n    private class EnumEntryLambda extends CustomLambda {\n        @Override","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java#L201-L237","documentation":"The scalaz client generator's toOperationId() rejects operationIds that are Scala reserved words, because the generated Scalaz/http4s client method could not be declared with that name in Scala. The RuntimeException names the offending word.","triggerScenarios":"-g scalaz on a spec with operationId: type / object / return / package / trait / match / implicit / lazy, etc. Single-word ids are not changed by camelize(operationId, LOWERCASE_FIRST_LETTER), so they reach the check intact.","commonSituations":"Operation ids mirroring domain verbs that collide with Scala keywords; specs shared across language generators where only the Scala one fails; keyword lists differing between Java and Scala (e.g. 'type', 'object', 'trait', 'implicit' fail here though they are legal elsewhere).","solutions":["Rename the operationId to a non-reserved word, ideally verb+noun (fetchType, buildObject)","Check the generator's reserved word list (reservedWords() in the Scala codegens) when picking ids","Add a CI lint step that rejects Scala reserved words in operationIds for Scala targets"],"exampleFix":"# before\npaths:\n  /schema:\n    get:\n      operationId: type\n# after\npaths:\n  /schema:\n    get:\n      operationId: getType","handlingStrategy":"validation","validationCode":"# Reject Scala reserved words as operationIds (Python):\nSCALA_RESERVED = {'abstract','case','catch','class','def','do','else','extends','false','final',\n                  'finally','for','forSome','if','implicit','import','lazy','match','new','null',\n                  'object','override','package','private','protected','return','sealed','super',\n                  'this','throw','trait','true','try','type','val','var','while','with','yield'}\nfor oid in all_operation_ids(spec):\n    assert oid not in SCALA_RESERVED, f'operationId {oid!r} is a Scala reserved word'","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(input).generate();\n} catch (RuntimeException e) {\n    // '<word> (reserved word) cannot be used as method name' - rename that operationId and rerun\n}","preventionTips":["Avoid single-keyword operationIds, especially Scala-only keywords like type, object, trait, implicit","Shared multi-language specs should lint against the union of target-language reserved words","camelize() will not rescue a bare keyword; only a rename fixes it"],"tags":["scala","scalaz","codegen","reserved-word","operationid","openapi-generator"],"backgroundTag":"reserved-word-identifier","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}