Skip to content

ChainlitDataLayer.create_element() blocks CustomElement persistence when no storage client is configured #2588

@jason-raitz

Description

@jason-raitz

Bug Description:

The ChainlitDataLayer.create_element() method currently requires a storage client to be configured, even for elements that don't need file uploads. This prevents CustomElement instances from being persisted when cloud storage is not configured. There are many custom UI elements listed in the documentation.

To Reproduce

  1. Set up a Chainlit project without configuring any cloud storage.
  2. Follow the guide to create a data layer.
  3. Follow the "full example" in the (Documentation)
  4. Run the project and see the custom element in the UI.
  5. Either look at the data layer and see that no element is created, or start a new conversation and click on the previous conversation to see that the custom element is not persisted.

Current behavior (from backend/chainlit/chainlit_data_layer.py):

@queue_until_user_message()
async def create_element(self, element: "Element"):
    if not self.storage_client:
        logger.warning(
            "Data Layer: create_element error. No cloud storage configured!"
        )
        return  # Short-circuits, preventing ANY element from being saved

Impact

  • Current documentation lists two examples and neither one will work without cloud storage configured, despite neither needing file uploads. (Full Example)
  • Users cannot persist CustomElement instances without configuring cloud storage (S3, GCS, or Azure)
  • This is overly restrictive since CustomElement only needs database storage for its props field
  • Other element types that have URLs but no binary content also cannot be persisted

Ideal Use Case

We should be able to use custom UI elements like the ones listed in the documentation without configuring cloud storage.

These elements should persist to the data layer even without cloud storage, if they contain no binary data.

Suggested Labels: bug, data-layer, enhancement

Possible Related issue:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions