{"record":{"id":"4b32c125133d35a3","repo":"kestra-io/kestra","slug":"select-option-object-must-define-a-value-field","errorCode":null,"errorMessage":"Select option object must define a `value` field","messagePattern":"Select option object must define a `value` field","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/models/flows/input/ValueOption.java","lineNumber":41,"sourceCode":" */\n@Schema(\n    description = \"A select option. Accepts either a plain string (used as both label and value) or an object with `label` and `value` fields.\",\n    anyOf = { String.class, ValueOption.ValueOptionObject.class }\n)\npublic record ValueOption(@NotNull String label, @NotNull String value) {\n\n    @JsonCreator\n    public static ValueOption from(Object raw) {\n        if (raw == null) {\n            return null;\n        }\n        if (raw instanceof ValueOption v) {\n            return v;\n        }\n        if (raw instanceof Map<?, ?> map) {\n            Object rawValue = map.get(\"value\");\n            if (rawValue == null) {\n                throw new IllegalArgumentException(\"Select option object must define a `value` field\");\n            }\n            Object rawLabel = map.containsKey(\"label\") ? map.get(\"label\") : rawValue;\n            return new ValueOption(rawLabel.toString(), rawValue.toString());\n        }\n        String str = raw.toString();\n        return new ValueOption(str, str);\n    }\n\n    @JsonValue\n    public Object toJson() {\n        if (Objects.equals(label, value)) {\n            return value;\n        }\n        Map<String, String> map = new LinkedHashMap<>();\n        map.put(\"label\", label);\n        map.put(\"value\", value);\n        return map;\n    }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/models/flows/input/ValueOption.java#L23-L59","documentation":"Thrown by ValueOption.from() when deserializing a SELECT input option from a Map that has no 'value' key. Each select option MUST carry a value (the option's underlying selection value); the label is optional and defaults to the value. This IllegalArgumentException surfaces during flow parsing/validation when an options entry is a JSON object missing the required value field.","triggerScenarios":"A SELECT input defines an option as {\"label\":\"Foo\"} with no value; an option map is {\"name\":\"x\"} instead of {\"value\":\"x\"}; malformed YAML/JSON in the flow's options list.","commonSituations":"Typo in the option key ('val' instead of 'value'); copy-paste from another schema; YAML auto-converted a key name.","solutions":["Ensure every object-form select option includes a 'value' field.","Use the string shorthand (just the value) for label-less options: options: [a, b, c].","Validate the flow YAML/JSON with a linter before submission."],"exampleFix":"# before\ninputs:\n  - id: choice\n    type: SELECT\n    options:\n      - label: Foo   # missing value\n\n# after\ninputs:\n  - id: choice\n    type: SELECT\n    options:\n      - value: foo\n        label: Foo\n      # or shorthand\n      - foo","handlingStrategy":"validation","validationCode":"if (raw instanceof Map<?,?> map && !map.containsKey(\"value\")) {\n    throw new IllegalArgumentException(\"Select option object must define a `value` field\");\n}","typeGuard":"function isValueOptionMap(o): o is { value: unknown; label?: unknown } {\n  return typeof o === 'object' && o !== null && 'value' in o;\n}","tryCatchPattern":"try {\n    ValueOption.from(raw);\n} catch (IllegalArgumentException e) {\n    // highlight the offending option in the flow editor\n    errors.add(\"Each SELECT option object needs a 'value' field.\");\n}","preventionTips":["Use the string shorthand for label-less options.","Validate flow YAML options client-side before submission."],"tags":["flow-input","validation","select","json"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}