{"record":{"id":"c9f6e86f7c7f5e71","repo":"cocoindex-io/cocoindex","slug":"livecomponent-classes-cannot-be-used-with-use-moun","errorCode":null,"errorMessage":"LiveComponent classes cannot be used with use_mount(). Use mount() instead.","messagePattern":"LiveComponent classes cannot be used with use_mount\\(\\)\\. Use mount\\(\\) instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/_internal/api.py","lineNumber":279,"sourceCode":"    if pos_args and isinstance(pos_args[0], ComponentSubpath):\n        subpath = pos_args[0]\n        processor_fn = pos_args[1]\n        args = pos_args[2:]\n    else:\n        processor_fn = pos_args[0]\n        args = pos_args[1:]\n        name = _default_subpath_name(processor_fn)\n        if name is None:\n            raise TypeError(\n                \"use_mount() requires a ComponentSubpath when the function has no \"\n                \"__name__. Provide an explicit subpath as the first argument.\"\n            )\n        subpath = ComponentSubpath(Symbol(name))\n\n    check_not_in_process_live(\"coco.use_mount\")\n\n    if is_live_component_class(processor_fn):\n        raise TypeError(\n            \"LiveComponent classes cannot be used with use_mount(). \"\n            \"Use mount() instead.\"\n        )\n\n    parent_ctx = get_context_from_ctx()\n    child_path = build_child_path(parent_ctx, subpath)\n    # One explicit value travels through core: capture once, pass to both\n    # the processor (ContextVar restore in the wrapper) and the engine call.\n    deadline_context = _deadline_for_engine()\n\n    processor = create_core_component_processor(\n        processor_fn,\n        parent_ctx._env,\n        child_path,\n        args,\n        kwargs,\n        deadline_context=deadline_context,\n    )","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/_internal/api.py#L261-L297","documentation":"LiveComponent classes own their own lifecycle and must be mounted with mount(), which returns a handle you can await for readiness. use_mount() is for plain functions whose result value is returned directly; combining the two is not supported, so the API rejects it up front.","triggerScenarios":"Calling coco.use_mount(SomeLiveComponentClass, ...) where the first argument is a class recognized by is_live_component_class().","commonSituations":"Confusing the two mounting APIs after refactoring a component from a function to a LiveComponent class (or copying a use_mount call and swapping in a class).","solutions":["Use coco.mount(SomeLiveComponentClass, *args) and await handle.ready() on the returned handle instead of use_mount()","If you actually need a return value, convert the class to a plain @coco.fn async function"],"exampleFix":"// before\nresult = await coco.use_mount(MyLiveComponent, cfg)\n// after\nhandle = await coco.mount(MyLiveComponent, cfg)\nawait handle.ready()","handlingStrategy":"type-guard","validationCode":"from cocoindex._internal.api import is_live_component_class  # or public equivalent\n\nif is_live_component_class(fn):\n    handle = await coco.mount(fn, *args)\nelse:\n    result = await coco.use_mount(fn, *args)","typeGuard":"def is_live_component(fn) -> bool:\n    return isinstance(fn, type)  # LiveComponents are classes; plain fns are not","tryCatchPattern":"try:\n    result = await coco.use_mount(fn, *args)\nexcept TypeError as e:\n    if \"LiveComponent\" in str(e):\n        await (await coco.mount(fn, *args)).ready()","preventionTips":["Remember: use_mount for value-returning functions, mount for LiveComponent classes","Keep components as functions unless a LiveComponent lifecycle is genuinely needed"],"tags":["python","api-misuse","type-mismatch"],"backgroundTag":"unsupported-operation","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}