{"record":{"id":"aae69ac7f25cc0bc","repo":"marmelab/react-admin","slug":"emptyvalue-being-set-to-null-or-undefined-is-not-s-aae69a","errorCode":null,"errorMessage":"emptyValue being set to null or undefined is not supported. Use parse to turn the empty string into null.","messagePattern":"emptyValue being set to null or undefined is not supported\\. Use parse to turn the empty string into null\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ra-ui-materialui/src/input/SelectInput.tsx","lineNumber":152,"sourceCode":"        label,\n        margin = 'dense',\n        onBlur,\n        onChange,\n        onCreate,\n        optionText,\n        optionValue,\n        parse,\n        resource: resourceProp,\n        source: sourceProp,\n        translateChoice,\n        validate,\n        ...rest\n    } = props;\n    const translate = useTranslate();\n\n    useEffect(() => {\n        if (emptyValue == null) {\n            throw new Error(\n                `emptyValue being set to null or undefined is not supported. Use parse to turn the empty string into null.`\n            );\n        }\n    }, [emptyValue]);\n\n    const {\n        allChoices,\n        isPending,\n        error: fetchError,\n        source,\n        resource,\n        isFromReference,\n    } = useChoicesContext({\n        choices: choicesProp,\n        isLoading: isLoadingProp,\n        isFetching: isFetchingProp,\n        isPending: isPendingProp,\n        resource: resourceProp,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/marmelab/react-admin/blob/051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0/packages/ra-ui-materialui/src/input/SelectInput.tsx#L134-L170","documentation":"SelectInput treats its empty option value specially: it must be a non-null value (typically the empty string '') so it can distinguish 'no selection' from an actual null choice. Passing emptyValue={null} or leaving it undefined when a custom empty value was intended is unsupported — the library tells you to use `parse` to convert '' to null instead, inside a useEffect check.","triggerScenarios":"Rendering <SelectInput ... emptyValue={null} /> or explicitly setting emptyValue={undefined}. The check runs in a useEffect, so it fires after the first render whenever emptyValue == null.","commonSituations":"Developers trying to make the 'no selection' option submit null to the API; wiring emptyValue from a variable that is null at runtime; misunderstanding that emptyText/emptyValue default handling already provides ''.","solutions":["Remove emptyValue (the default '' is used) and add `parse={v => v === '' ? null : v}` if the form value should be null.","Set emptyValue to a concrete non-null sentinel such as '' or a string like 'none'."],"exampleFix":"// before\n<SelectInput source=\"category\" choices={choices} emptyValue={null} />\n\n// after\n<SelectInput\n  source=\"category\"\n  choices={choices}\n  parse={value => (value === '' ? null : value)}\n/>","handlingStrategy":"validation","validationCode":"if (emptyValue === null || emptyValue === undefined) {\n  throw new Error('emptyValue must be non-null; use parse to map \"\" to null');\n}","typeGuard":"const isValidEmptyValue = (v: unknown): v is string | number | boolean =>\n  v !== null && v !== undefined;","tryCatchPattern":null,"preventionTips":["Never pass null/undefined as emptyValue","Use parse={value => value === '' ? null : value} to submit null to the API","If emptyValue comes from config, validate it at load time"],"tags":["react-admin","select-input","props","null-handling"],"backgroundTag":"invalid-null-prop","analyzedSha":"051f511bb0afb5ea565c2d3728bf4dab0a6fa5e0","analyzedAt":"2026-08-30T02:28:14.926Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}