{"record":{"id":"ad561c0f45e121b9","repo":"OpenAPITools/openapi-generator","slug":"invalid-datelibrary-must-be-java8-or-joda","errorCode":null,"errorMessage":"Invalid dateLibrary. Must be 'java8' or 'joda'","messagePattern":"Invalid dateLibrary\\. Must be 'java8' or 'joda'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java","lineNumber":263,"sourceCode":"            this.importMapping.put(\"LocalTime\", \"org.joda.time.LocalTime\");\n            this.typeMapping.put(\"date\", \"LocalDate\");\n            this.typeMapping.put(\"DateTime\", \"DateTime\");\n            additionalProperties.put(\"joda\", \"true\");\n        }\n    }\n\n    public void setDateLibrary(String dateLibrary, boolean withLegacy) {\n        if (withLegacy && dateLibrary.equals(DateLibraries.legacy.name())) {\n            this.dateLibrary = dateLibrary;\n            return;\n        }\n        for (DateLibraries dateLib : DateLibraries.values()) {\n            if (dateLib.name().equals(dateLibrary)) {\n                this.dateLibrary = dateLibrary;\n                return;\n            }\n        }\n        throw new IllegalArgumentException(\"Invalid dateLibrary. Must be 'java8' or 'joda'\");\n    }\n\n    public void setModelPropertyNaming(String naming) {\n        try {\n            this.modelPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.valueOf(naming).name();\n        } catch (IllegalArgumentException ex) {\n            throw new IllegalArgumentException(\"Invalid model property naming '\" +\n                    naming + \"'. Must be 'original', 'camelCase', \" +\n                    \"'PascalCase' or 'snake_case'\");\n        }\n    }\n\n\n    @Override\n    public String toVarName(String name) {\n        // obtain the name from nameMapping directly if provided\n        if (nameMapping.containsKey(name)) {\n            return nameMapping.get(name);","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java#L245-L281","documentation":"AbstractScalaCodegen.setDateLibrary matches the given string against the DateLibraries enum — java8, joda, legacy — where legacy is only honored when the caller passes withLegacy=true. A no-match throws IllegalArgumentException('Invalid dateLibrary. Must be java8 or joda'). The message is stale: 'legacy' is also valid on generators that opt in, and matching is exact and case-sensitive.","triggerScenarios":"-p dateLibrary=<bad> on any Scala-based generator (akka-scala, scala-finch, scala-gatling, scalatra, play-scala, http4s, ...) with a value that is not exactly 'java8', 'joda', or an opted-in 'legacy': 'Java8', 'java-8', 'threetenbp', 'java.time' all throw.","commonSituations":"Copying dateLibrary values from Java-generator docs (threetenbp does not exist here); case typos; trusting the stale message as the complete option list.","solutions":["Use exactly java8 (the default) or joda, all lowercase","For the deprecated backport, use legacy only on generators whose setDateLibrary call passes withLegacy=true (e.g. -g scala)","Check that generator's README option table for its supported dateLibrary values before setting it"],"exampleFix":"# before\njava -jar openapi-generator-cli.jar generate -g akka-scala -i api.yaml -p dateLibrary=threetenbp\n\n# after\njava -jar openapi-generator-cli.jar generate -g akka-scala -i api.yaml -p dateLibrary=java8","handlingStrategy":"validation","validationCode":"// Java/bash: whitelist before setting the option\n// allowed (Scala base): java8, joda, legacy (only where the generator opts in)\nSet<String> allowed = Set.of(\"java8\", \"joda\", \"legacy\");\nif (!allowed.contains(dateLibrary)) throw new IllegalArgumentException(\"bad dateLibrary: \" + dateLibrary);","typeGuard":null,"tryCatchPattern":"try { generator.generate(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Invalid dateLibrary\")) { /* use exact lowercase java8/joda (or opted-in legacy) */ } throw e; }","preventionTips":["Check the specific Scala generator's README for its dateLibrary values","Values are case-sensitive: lowercase only","Do not port threetenbp or other Java-generator values to Scala generators"],"tags":["scala","configuration","cli-option","date-library"],"backgroundTag":"invalid-generator-option","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}