{"record":{"id":"7ab8f7b8f78284ed","repo":"xai-org/x-algorithm","slug":"no-partitions-found-for-topic-topic-available","errorCode":null,"errorMessage":"No partitions found for topic '{topic}'. Available topics: {available}","messagePattern":"No partitions found for topic '(.+?)'\\. Available topics: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"phoenix/xrex/data/streaming/kafkaconsumer.py","lineNumber":458,"sourceCode":"    consumer = AIOKafkaConsumer(\n        bootstrap_servers=bootstrap_servers,\n        security_protocol=\"SASL_SSL\",\n        sasl_kerberos_domain_name=\"kafka\",\n        sasl_kerberos_service_name=\"kafka\",\n        sasl_mechanism=sasl_mechanism,\n        sasl_plain_username=sasl_plain_username,\n        sasl_plain_password=sasl_plain_password,\n        ssl_context=ssl_ctx,\n        request_timeout_ms=30000,\n    )\n    await consumer.start()\n    try:\n        partitions = consumer.partitions_for_topic(topic)\n        if not partitions:\n            partitions = await force_kafka_metadata_update(consumer, topic)\n        if not partitions:\n            available = await consumer.topics()\n            raise ValueError(\n                f\"No partitions found for topic '{topic}'. Available topics: {available}\"\n            )\n        count = len(partitions)\n        rank_logger.info(f\"Discovered {count} partitions for topic '{topic}' from Kafka metadata.\")\n        return count\n    finally:\n        try:\n            await consumer.stop()\n        except asyncio.CancelledError:\n            pass\n\n\ndef _range_partitions(total_partitions: int, shard_index: int, num_shards: int) -> list[int]:\n    if num_shards <= 0:\n        raise ValueError(f\"num_shards must be > 0, got {num_shards}\")\n    if total_partitions < 0:\n        raise ValueError(f\"total_partitions must be >= 0, got {total_partitions}\")\n    start = shard_index * total_partitions // num_shards","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/data/streaming/kafkaconsumer.py#L440-L476","documentation":"Raised by discover_partition_count when the Kafka consumer cannot find any partitions for the requested topic, even after a forced metadata refresh. The error lists all topics visible from cluster metadata so you can see what Kafka actually knows about. It almost always means the topic does not exist, is misspelled, or the broker cluster the client is connected to has no such topic.","triggerScenarios":"Calling ensure_partition_count/consumption_loop with a topic name that does not exist on the brokers pointed to by bootstrap_servers; topic auto-creation disabled (auto.create.topics.enable=false) so the producer never created it; connected to the wrong cluster/environment; ACLs hiding the topic from the client.","commonSituations":"Typo in the topic name in config; pointing at a staging bootstrap server while the topic only exists in production; Kafka cluster migrated and old topic names removed; topic not yet created by an infrastructure/Terraform step; brokers unreachable so metadata comes back empty.","solutions":["Compare the topic name against the 'Available topics' list in the error message and fix typos/case in your config.","Verify you are connecting to the right cluster: check bootstrap_servers environment/flags and run kafka-topics --bootstrap-server <brokers> --list.","If the topic genuinely does not exist, create it (kafka-topics --create ...) or enable auto-create, then retry.","If the topic exists but is not listed, check ACL/permissions for the client principal and broker advertised.listeners reachability."],"exampleFix":"# before\npartitions = await discover_partition_count(consumer, \"my-topc\")\n\n# after\npartitions = await discover_partition_count(consumer, \"my-topic\")  # match 'Available topics' from error","handlingStrategy":"validation","validationCode":"async def topic_exists(consumer, topic: str) -> bool:\n    return bool(await consumer.partitions_for_topic(topic))","typeGuard":null,"tryCatchPattern":"try:\n    count = await discover_partition_count(consumer, topic)\nexcept ValueError as e:\n    if \"No partitions found\" in str(e):\n        rank_logger.error(f\"Topic not visible; check bootstrap_servers/topic name: {e}\")\n        raise","preventionTips":["Validate topic names against a config schema at startup.","Run a preflight kafka-topics --describe in deploy scripts.","Wait for metadata propagation after topic creation before starting consumers."],"tags":["kafka","topic-not-found","metadata","config"],"backgroundTag":"kafka-topic-not-found","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}