Skip to content

ChromaCloudQwenEmbeddingFunction.build_from_config rejects task=None that get_config() emits #7450

Description

@winklemad

Bug

ChromaCloudQwenEmbeddingFunction treats task as optional everywhere except build_from_config, so a collection whose Qwen embedding function was created with task=None cannot be reloaded.

  • The constructor signature is task: Optional[str], and the docstring says "If None or empty, empty instructions will be used".
  • The runtime (__call__ / embed_query) handles task=None (if self.task and ...).
  • The JSON schema schemas/embedding_functions/chroma-cloud-qwen.json declares "task": {"type": ["string", "null"]}.
  • get_config() emits {"task": None, ...} for such an EF, and validate_config() accepts it.

But build_from_config guards with if model is None or task is None: assert False, "Config is missing a required field". So reloading a persisted collection whose Qwen EF used task=None raises AssertionError, which load_collection_configuration_from_json re-wraps as ValueError("Could not build embedding function ...") — the collection becomes unusable.

Reproduction

import os
os.environ["CHROMA_API_KEY"] = "dummy"   # __init__ only needs a non-empty key; no network call
from chromadb.utils.embedding_functions.chroma_cloud_qwen_embedding_function import (
    ChromaCloudQwenEmbeddingFunction as EF, ChromaCloudQwenEmbeddingModel as M)

ef = EF(model=M.QWEN3_EMBEDDING_0p6B, task=None)   # valid per signature/docstring/schema
cfg = ef.get_config()                              # {"task": None, ...}
EF.validate_config(cfg)                            # passes (schema permits null)
EF.build_from_config(cfg)                          # AssertionError: Config is missing a required field

Fix

Only model is actually required; drop task from the guard:

-        if model is None or task is None:
+        if model is None:
             assert False, "Config is missing a required field"

PR incoming, with a real (non-mocked) get_configbuild_from_config round-trip regression test (the existing parametrized round-trip test mocks build_from_config, so it never exercised this path).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions