{"record":{"id":"4f68d8b75b413c7a","repo":"reflex-dev/reflex","slug":"the-function-names-should-be-str-names-of-function","errorCode":null,"errorMessage":"the function names should be str names of functions in the specified transformer: {library!r}","messagePattern":"the function names should be str names of functions in the specified transformer: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-code/src/reflex_components_code/shiki_code_block.py","lineNumber":668,"sourceCode":"        return imports\n\n    @classmethod\n    def create_transformer(cls, library: str, fns: list[str]) -> ShikiBaseTransformers:\n        \"\"\"Create a transformer from a third party library.\n\n        Args:\n            library: The name of the library.\n            fns: The str names of the functions/callables to invoke from the library.\n\n        Returns:\n            A transformer for the specified library.\n\n        Raises:\n            ValueError: If a supplied function name is not valid str.\n        \"\"\"\n        if any(not isinstance(fn_name, str) for fn_name in fns):\n            msg = f\"the function names should be str names of functions in the specified transformer: {library!r}\"\n            raise ValueError(msg)\n        return ShikiBaseTransformers(\n            library=library,\n            fns=[FunctionStringVar.create(fn) for fn in fns],  # pyright: ignore [reportCallIssue]\n        )\n\n    def _render(self, props: dict[str, Any] | None = None):\n        \"\"\"Renders the component with the given properties, processing transformers if present.\n\n        Args:\n            props: Optional properties to pass to the render function.\n\n        Returns:\n            Rendered component output.\n        \"\"\"\n        # Ensure props is initialized from class attributes if not provided\n        props = props or {\n            attr.rstrip(\"_\"): getattr(self, attr) for attr in self.get_props()\n        }","sourceCodeStart":650,"sourceCodeEnd":686,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-code/src/reflex_components_code/shiki_code_block.py#L650-L686","documentation":"Raised by reflex_components_code.shiki_code_block.create_transformer when one of the function names passed in `fns` is not a Python str. The transformer API compiles function names into FunctionStringVar instances, so only string names of exported functions in the target transformer library are accepted.","triggerScenarios":"Calling create_transformer('rehype-remark', fns=[SomeFunction]) or passing a callable, None, or imported function object instead of the string function name in the `fns` list.","commonSituations":"Developers import a transformer function directly (e.g. `import rehypeSlug from ...`) and pass the imported object instead of the string 'rehypeSlug'; or they build the fns list dynamically and accidentally include None.","solutions":["Pass the names of the transformer functions as plain strings, e.g. fns=['rehypeSlug']","If building fns programmatically, coerce each entry with str(fn) only if it really is a name","Check for None entries before calling create_transformer"],"exampleFix":"// before\ncreate_transformer(\"rehype-slug\", fns=[rehype_slug])\n\n// after\ncreate_transformer(\"rehype-slug\", fns=[\"rehypeSlug\"])","handlingStrategy":"validation","validationCode":"fns = [fn for fn in fns if fn is not None]\nassert all(isinstance(fn, str) for fn in fns), fns","typeGuard":"def is_fn_names(fns: list) -> bool:\n    return all(isinstance(fn, str) for fn in fns)","tryCatchPattern":null,"preventionTips":["Always quote transformer function names as strings","Lint for non-str entries when building fns dynamically"],"tags":["shiki","transformer","type-validation"],"backgroundTag":"invalid-argument-type","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}