{"record":{"id":"154b0406b5e4cc72","repo":"reflex-dev/reflex","slug":"you-must-specify-either-children-or-src-for-the-sc","errorCode":null,"errorMessage":"You must specify either children or src for the script element.","messagePattern":"You must specify either children or src for the script element\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/base/script.py","lineNumber":56,"sourceCode":"        integrity = props.pop(\"integrity\", None)\n        referrer_policy = props.pop(\"referrer_policy\", None)\n        src = props.pop(\"src\", None)\n        type = props.pop(\"type\", None)\n        key = props.pop(\"key\", None)\n        id = props.pop(\"id\", None)\n        class_name = props.pop(\"class_name\", None)\n        custom_attrs = props.pop(\"custom_attrs\", None)\n        on_mount = props.pop(\"on_mount\", None)\n        on_unmount = props.pop(\"on_unmount\", None)\n\n        if props:\n            logger.warning(\n                f\"rx.script does not support the following properties: {list(props.keys())}\"\n            )\n\n        if not children and not src:\n            msg = \"You must specify either children or src for the script element.\"\n            raise ValueError(msg)\n\n        return helmet(\n            elements.Script.create(\n                *children,\n                async_=async_,\n                char_set=char_set,\n                cross_origin=cross_origin,\n                defer=defer,\n                integrity=integrity,\n                referrer_policy=referrer_policy,\n                src=src,\n                type=type,\n                key=key,\n                id=id,\n                class_name=class_name,\n                custom_attrs=custom_attrs,\n                on_mount=on_mount,\n                on_unmount=on_unmount,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/base/script.py#L38-L74","documentation":"rx.script requires exactly one source of script content: either inline children (the script body) or the `src` attribute pointing at an external file. Neither being present means there is nothing to render into the helmet script tag, so create() raises ValueError.","triggerScenarios":"Calling rx.script() with no arguments, or rx.script(id='x', type='module') passing only attributes without children or src.","commonSituations":"Copy-pasting a script tag and stripping the body during refactor; conditionally building children that end up empty (e.g. \"\".join(parts) yielding nothing).","solutions":["Provide inline code: rx.script(\"console.log('hi')\")","Or reference an external file: rx.script(src='/js/analytics.js')","Guard conditional scripts: only call rx.script when the body string is non-empty"],"exampleFix":"// before\nrx.script(src=None)  # nothing\n\n// after\nrx.script(\"console.log('hi')\")\n# or\nrx.script(src=\"/js/analytics.js\")","handlingStrategy":"validation","validationCode":"assert children or src, \"rx.script needs children or src\"","typeGuard":"def has_script_source(children, src) -> bool:\n    return bool(children) or bool(src)","tryCatchPattern":null,"preventionTips":["Always provide either inline code or src","Guard conditional script bodies with if body: rx.script(body)"],"tags":["script","prop-validation"],"backgroundTag":"missing-required-prop","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}