{"record":{"id":"b4a91f656e9ef8c4","repo":"OpenAPITools/openapi-generator","slug":"unable-to-deserialize-config-file-configfile","errorCode":null,"errorMessage":"Unable to deserialize config file: {configFile}","messagePattern":"Unable to deserialize config file: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java","lineNumber":203,"sourceCode":"        ObjectMapper mapper;\n\n        if (FilenameUtils.isExtension(configFile.toLowerCase(Locale.ROOT), new String[]{\"yml\", \"yaml\"})) {\n            mapper = Yaml.mapper().copy();\n        } else {\n            mapper = Json.mapper().copy();\n        }\n\n        if (modules != null && modules.length > 0) {\n            mapper.registerModules(modules);\n        }\n\n        mapper.registerModule(new GuavaModule());\n\n        try {\n            return mapper.readValue(new File(configFile), DynamicSettings.class);\n        } catch (IOException ex) {\n            LOGGER.error(ex.getMessage());\n            throw new RuntimeException(\"Unable to deserialize config file: \" + configFile);\n        }\n    }\n\n    public CodegenConfigurator addServerVariable(String key, String value) {\n        this.serverVariables.put(key, value);\n        generatorSettingsBuilder.withServerVariable(key, value);\n        return this;\n    }\n\n    public CodegenConfigurator addAdditionalProperty(String key, Object value) {\n        this.additionalProperties.put(key, value);\n        generatorSettingsBuilder.withAdditionalProperty(key, value);\n        return this;\n    }\n\n    public CodegenConfigurator addAdditionalReservedWordMapping(String key, String value) {\n        this.reservedWordsMappings.put(key, value);\n        generatorSettingsBuilder.withReservedWordMapping(key, value);","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java#L185-L221","documentation":"CodegenConfigurator's config-file loader uses Jackson to read the file into DynamicSettings; any IOException (missing file, unreadable file, or YAML/JSON syntax error) is logged and rethrown as this RuntimeException. Note the original IOException is logged but not chained onto the thrown exception, so stack traces show only the wrapper — check the log line above the stack trace for the real cause. The config file is the JSON/YAML passed via -c/--config-file.","triggerScenarios":"-c config.json that doesn't exist (FileNotFoundException is an IOException); a JSON/YAML file with syntax errors; a config file whose structure does not match DynamicSettings binding; passing a spec file where the config file was expected.","commonSituations":"Relative config paths resolved from a different working directory in CI/maven plugins; YAML tabs or trailing commas; swapping -i (spec) and -c (config) arguments; template placeholders like ${...} left in the config from templated pipelines.","solutions":["Check the logged line above the exception — it carries the underlying Jackson/FileNotFound message; fix that (path, syntax, or structure).","Validate the file parses: run it through `jq` (JSON) or `yamllint` (YAML) before generation.","Use an absolute path for -c, or confirm the working directory the CLI/maven plugin resolves relative paths from.","Compare your keys against a known-good config (generate with --dry-run or copy from the generator docs)."],"exampleFix":"# before: trailing comma\n{ \"groupId\": \"com.acme\", }\n# after\n{ \"groupId\": \"com.acme\" }","handlingStrategy":"validation","validationCode":"// Parse and structurally check the config before handing it to the generator\nObjectNode cfg = (ObjectNode) new ObjectMapper(new YAMLFactory()).readTree(new File(configFile));\nfor (String known : List.of(\"groupId\", \"artifactId\", \"artifactVersion\", \"java8\", \"library\")) {\n    // warn on unknown keys that look like typos of known ones\n}\n// readTree succeeding guarantees the syntax is valid before CodegenConfigurator runs","typeGuard":null,"tryCatchPattern":"try { configurator.loadConfigFile(...); } catch (RuntimeException e) { log.error(\"config file {} invalid — see earlier log line for Jackson cause\", path); fail build with clear message; }","preventionTips":["Validate config files with yamllint/jq in CI.","Use absolute paths for -c.","Never template placeholder syntax into config files; render them first."],"tags":["openapi","config-file","json","yaml","deserialization"],"backgroundTag":"config-file-parse-error","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}