{"record":{"id":"7c2ada9f16384022","repo":"chroma-core/chroma","slug":"expected-collection-name-that-1-contains-3-63-ch","errorCode":null,"errorMessage":"Expected collection name that (1) contains 3-63 characters, (2) starts and ends with an alphanumeric character, (3) otherwise contains only alphanumeric characters, underscores or hyphens (-), (4) contains no two consecutive periods (..) and (5) is not a valid IPv4 address, got {index_name}","messagePattern":"Expected collection name that \\(1\\) contains 3-63 characters, \\(2\\) starts and ends with an alphanumeric character, \\(3\\) otherwise contains only alphanumeric characters, underscores or hyphens \\(-\\), \\(4\\) contains no two consecutive periods \\(\\.\\.\\) and \\(5\\) is not a valid IPv4 address, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/segment.py","lineNumber":109,"sourceCode":"\nT = TypeVar(\"T\", bound=Callable[..., Any])\n\nlogger = logging.getLogger(__name__)\n\n\n# mimics s3 bucket requirements for naming\ndef check_index_name(index_name: str) -> None:\n    msg = (\n        \"Expected collection name that \"\n        \"(1) contains 3-63 characters, \"\n        \"(2) starts and ends with an alphanumeric character, \"\n        \"(3) otherwise contains only alphanumeric characters, underscores or hyphens (-), \"\n        \"(4) contains no two consecutive periods (..) and \"\n        \"(5) is not a valid IPv4 address, \"\n        f\"got {index_name}\"\n    )\n    if len(index_name) < 3 or len(index_name) > 63:\n        raise ValueError(msg)\n    if not re.match(\"^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$\", index_name):\n        raise ValueError(msg)\n    if \"..\" in index_name:\n        raise ValueError(msg)\n    if re.match(\"^[0-9]{1,3}\\\\.[0-9]{1,3}\\\\.[0-9]{1,3}\\\\.[0-9]{1,3}$\", index_name):\n        raise ValueError(msg)\n\n\ndef rate_limit(func: T) -> T:\n    @wraps(func)\n    def wrapper(*args: Any, **kwargs: Any) -> Any:\n        self = args[0]\n        return self._rate_limit_enforcer.rate_limit(func)(*args, **kwargs)\n\n    return wrapper  # type: ignore\n\n\nclass SegmentAPI(ServerAPI):","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/segment.py#L91-L127","documentation":"check_index_name (chromadb/api/segment.py:105) validates collection names with S3-bucket-style rules. This raise site (line 109) fires when the name is shorter than 3 or longer than 63 characters. The same message is reused by the charset, double-period, and IPv4 checks, so the text alone does not say which rule failed.","triggerScenarios":"client.create_collection(name='ab') (2 chars) or a name longer than 63 chars; also client.get_or_create_collection / any API path that validates a new collection name. Only the length branch - len(name) < 3 or len(name) > 63 - produces this instance.","commonSituations":"Auto-generating collection names from user IDs, dates, or slugs that end up 1-2 characters; truncating names with [:60] plus a suffix pushing past 63; test fixtures using names like 't' or 'c1'.","solutions":["Rename the collection to 3-63 characters (e.g. 'ab' -> 'ab_collection')","When generating names programmatically, pad or prefix short identifiers and clamp total length to <= 63","Pre-validate with the same rule (see validation helper) before calling create_collection"],"exampleFix":"# before\nclient.create_collection(name='ab')  # ValueError: 2 chars\n\n# after\nclient.create_collection(name='ab_collection')  # 13 chars - valid","handlingStrategy":"validation","validationCode":"import re\n\ndef valid_collection_name(name: str) -> bool:\n    \"\"\"Mirror chromadb.api.segment.check_index_name.\"\"\"\n    if not (3 <= len(name) <= 63):\n        return False\n    if not re.match(r'^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$', name):\n        return False\n    if '..' in name:\n        return False\n    if re.match(r'^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$', name):\n        return False\n    return True\n\n# use before creating:\n# assert valid_collection_name(name), f'bad collection name: {name!r}'","typeGuard":"from typing import Tuple\n\ndef check_name_or_raise(name: str) -> Tuple[bool, str]:\n    if len(name) < 3 or len(name) > 63:\n        return False, 'length must be 3-63'\n    return True, ''","tryCatchPattern":"try:\n    client.create_collection(name=name)\nexcept ValueError as e:\n    if 'Expected collection name' in str(e):\n        name = f'app-{name}'[:63].rstrip('._-')\n        client.create_collection(name=name)\n    else:\n        raise","preventionTips":["Clamp generated names to 3-63 characters with padding/truncation at the source","Never pass raw user input or empty variables as collection names","Centralize name construction in one helper that runs the full validation rule set"],"tags":["chroma","collection-name","validation","python"],"backgroundTag":"invalid-collection-name","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}