{"record":{"id":"eb59e4ddce08462f","repo":"OpenAPITools/openapi-generator","slug":"must-be-one-of-skip-fail-but-was","errorCode":null,"errorMessage":"{} must be one of [SKIP, FAIL] but was: {}","messagePattern":"(.+?) must be one of \\[SKIP, FAIL\\] but was: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/JsonAnnotationPolicyUtils.java","lineNumber":299,"sourceCode":"    /**\n     * Validate and normalize the {@code optionalNonNullPropertyJsonSetterNulls} config option value.\n     *\n     * @param value      the raw config option value\n     * @param optionName the config option name, used in the error message\n     * @return the normalized {@link JsonSetterNullsMode} ({@code SKIP} or {@code FAIL})\n     * @throws IllegalArgumentException when the value is not {@code SKIP} or {@code FAIL}\n     */\n    public static JsonSetterNullsMode normalizeJsonSetterNulls(String value, String optionName) {\n        JsonSetterNullsMode parsed = null;\n        if (value != null) {\n            try {\n                parsed = JsonSetterNullsMode.valueOf(value.trim().toUpperCase(java.util.Locale.ROOT));\n            } catch (IllegalArgumentException e) {\n                parsed = null;\n            }\n        }\n        if (parsed != JsonSetterNullsMode.SKIP && parsed != JsonSetterNullsMode.FAIL) {\n            throw new IllegalArgumentException(optionName + \" must be one of [SKIP, FAIL] but was: \" + value);\n        }\n        return parsed;\n    }\n\n    /**\n     * Read back the {@code optionalNonNullPropertyJsonSetterNulls} config option from\n     * {@code additionalProperties}, validating/normalizing it via {@link #normalizeJsonSetterNulls}. Returns\n     * {@code current} unchanged when the option was not present (i.e. the generator's existing/default value,\n     * typically {@code null} = unset, is kept).\n     *\n     * @param additionalProperties the generator's additional properties map\n     * @param current               the generator's current {@code optionalNonNullPropertyJsonSetterNulls} value\n     * @return the resolved {@link JsonSetterNullsMode} ({@code null} when left unset)\n     */\n    public static JsonSetterNullsMode resolveOptionalNonNullPropertyJsonSetterNulls(Map<String, Object> additionalProperties, JsonSetterNullsMode current) {\n        if (!additionalProperties.containsKey(CodegenConstants.OPTIONAL_NON_NULL_PROPERTY_JSON_SETTER_NULLS)) {\n            return current;\n        }","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/JsonAnnotationPolicyUtils.java#L281-L317","documentation":"JsonAnnotationPolicyUtils.normalizeJsonSetterNulls validates the spring/kotlin-spring option 'optionalNonNullPropertyJsonSetterNulls', which controls whether optional non-nullable properties get @JsonSetter(nulls = SKIP) (ignore explicit JSON nulls) or Nulls.FAIL (reject them). Only SKIP and FAIL are accepted — notably NONE is NOT valid here (it is reserved for the per-property extension), and a null/absent option simply skips normalization.","triggerScenarios":"Generating with -DoptionalNonNullPropertyJsonSetterNulls=NONE (common mistake — NONE looks like a safe 'off' value), =skip_nulls, or any other string. valueOf runs on the trimmed uppercase value, so 'skip' works but 'Skip nulls' does not.","commonSituations":"Trying to disable the feature by passing NONE (it is invalid for the option — just leave it unset); translating Jackson's Nulls.SKIP/FAIL docs into option values with extra words; sharing one options bundle between spring and kotlin-spring builds.","solutions":["Use exactly SKIP or FAIL.","To turn the behavior off, remove the option entirely — when unset, the mode is derived from openApiNullable (true -> FAIL where supported, false -> SKIP).","Per-property opt-out goes in the spec as x-jackson-json-setter-nulls: NONE instead."],"exampleFix":"# before\nopenapi-generator-cli generate -g spring \\\n  -DoptionalNonNullPropertyJsonSetterNulls=NONE\n\n# after\nopenapi-generator-cli generate -g spring\n# omit the option, or use -DoptionalNonNullPropertyJsonSetterNulls=SKIP","handlingStrategy":"validation","validationCode":"case \"$(printf '%s' \"$OPT_NONNULL_JSON_SETTER_NULLS\" | tr '[:lower:]' '[:upper:]' | tr -d ' ')\" in\n  SKIP|FAIL|\"\") ;;\n  *) echo \"ERROR: optionalNonNullPropertyJsonSetterNulls must be SKIP or FAIL (omit it to disable)\" >&2; exit 1;;\nesac","typeGuard":"const isJsonSetterNullsOption = (v: string): v is 'SKIP' | 'FAIL' =>\n  ['SKIP', 'FAIL'].includes(v.trim().toUpperCase());","tryCatchPattern":null,"preventionTips":["NONE is not a valid value for this option — to disable, omit it.","Use per-property x-jackson-json-setter-nulls: NONE for individual opt-outs."],"tags":["jackson","spring","codegen","config-validation"],"backgroundTag":"invalid-option-value","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}