projectlombok/lombok · error · InvalidFormatOptionException
Unknown format key: ' '.
Error message
Unknown format key: '%s'.
What it means
After splitting a --format option on ':', formatOptionsToMap validates the key against FormatPreferences.getKeysAndDescriptions(). If the key does not case-insensitively match any known format key, it throws InvalidFormatOptionException("Unknown format key: '%s'.").
Solutions
- Check the exact key list via FormatPreferences.getKeysAndDescriptions() or delombok --help and correct the spelling
- Use --format pretty as a shortcut for common preferences
- Pin documentation/tooling to your lombok version, since available format keys can change between releases
Example fix
// before delombok src -d out -f tabwidth:4 // after delombok src -d out -f indent:4
Defensive patterns
Strategy: validation
Validate before calling
Set<String> keys = FormatPreferences.getKeysAndDescriptions().keySet();
String k = opt.substring(0, opt.indexOf(':'));
boolean ok = keys.stream().anyMatch(k::equalsIgnoreCase);
if (!ok) throw new IllegalArgumentException("Unknown format key: " + k + "; valid: " + keys); Try / catch
try { delombok.formatOptionsToMap(opts); } catch (InvalidFormatOptionException e) { System.err.println(e.getMessage() + " Run with --help for valid keys"); System.exit(2); } Prevention
- Verify key names against your lombok version's documentation
- Tab-complete or copy key names instead of retyping
- Remember config keys and delombok --format keys are separate namespaces
When it happens
Trigger: Passing -f unknownkey:value where unknownkey is not one of the supported format keys (typo, renamed key, or a key from a different tool), e.g. -f tabwidth:4 instead of the supported indentation key.
Common situations: Typos in format keys, remembering keys from lombok versions where they were renamed, confusing delombok format keys with lombok.config keys, or guessing key names from documentation of another version.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Format keys need to be 2 values separated with a colon.
- DELOMBOK: delombok will only write to a directory. If you…
- Legal values for 'emptyLines' are 'scan', 'indent', or…
- Unclosed backslash escape in @ file
- Unclosed " in @ file
AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07).
Data as JSON: /api/errors/86b240a51ef4fb69.
Report an issue: GitHub.
Appendix: source
Thrown at src/delombok/lombok/delombok/Delombok.java:481
int idx = format.indexOf(':');
if (idx == -1) {
if (format.equalsIgnoreCase("pretty")) {
prettyEnabled = true;
continue;
} else {
throw new InvalidFormatOptionException("Format keys need to be 2 values separated with a colon.");
}
}
String key = format.substring(0, idx);
String value = format.substring(idx + 1);
boolean valid = false;
for (String k : FormatPreferences.getKeysAndDescriptions().keySet()) {
if (k.equalsIgnoreCase(key)) {
valid = true;
break;
}
}
if (!valid) throw new InvalidFormatOptionException("Unknown format key: '" + key + "'.");
formatPrefs.put(key.toLowerCase(), value);
}
if (prettyEnabled) {
if (!formatPrefs.containsKey("suppresswarnings")) formatPrefs.put("suppresswarnings", "skip");
if (!formatPrefs.containsKey("generated")) formatPrefs.put("generated", "skip");
if (!formatPrefs.containsKey("dancearoundidechecks")) formatPrefs.put("dancearoundidechecks", "skip");
if (!formatPrefs.containsKey("generatedelombokcomment")) formatPrefs.put("generatedelombokcomment", "skip");
if (!formatPrefs.containsKey("javalangasfqn")) formatPrefs.put("javalangasfqn", "skip");
}
return formatPrefs;
}
public void setFormatPreferences(Map<String, String> prefs) {
this.formatPrefs = prefs;
}
View on GitHub (pinned to 6d6a3e9fec)