{"record":{"id":"1d8351547b3e7bb1","repo":"xai-org/x-algorithm","slug":"conflict-config-name-nameseq-mkstring","errorCode":null,"errorMessage":"Conflict config name:${nameSeq.mkString}","messagePattern":"Conflict config name:(.+?)","errorType":"validation","errorClass":"ConfigFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/scala/com/twitter/botmaker/runtime/config/ServiceConfigs.scala","lineNumber":49,"sourceCode":"abstract class ServiceConfigs extends ConfigContainer with Debuggable {\n\n  private final val container = mutable.Map[String, (Type, String, AnyRef)]()\n  private final val uniqueNames = mutable.Set[Seq[Any]]()\n  private final val thriftTypeConfigs = mutable.Map[String, ThriftTypeConfig]()\n  private final val structTupleTypeConfigs = mutable.Map[String, StructTupleTypeConfig]()\n\n  val eventTypeRegex: Regex = \"^[a-z][a-z0-9_]*$\".r\n  val fieldNameRegex: Regex = \"^[a-zA-Z_][a-zA-Z0-9_]*$\".r\n  val funcNameRegex: Regex = \"^[A-Z][a-zA-Z0-9_]*$\".r\n  val endpointRegex: Regex = \"^[a-z][a-zA-Z0-9_]*$\".r\n  val datasetRegex: Regex = \"^[a-zA-Z_][a-zA-Z0-9_]*$\".r\n  val typeNameRegex: Regex = \"^[A-Z][a-zA-Z0-9_]*$\".r\n  val teamNameRegex: Regex = \"^[a-z][a-z0-9\\\\-]*$\".r\n\n  def unique(names: Any*): Unit = synchronized {\n    val nameSeq = names.toSeq\n    if (uniqueNames.contains(nameSeq)) {\n      throw ConfigFailure(\n        s\"Conflict config name:${nameSeq.mkString}\"\n      )\n    }\n    uniqueNames += nameSeq\n  }\n\n  def validate(condition: Boolean, err: String): Unit = {\n    if (!condition) {\n      throw ConfigFailure(err)\n    }\n  }\n\n  def validateEventType(eventType: String): Unit = {\n    if (eventTypeRegex.findFirstIn(eventType).isEmpty) {\n      throw ConfigFailure(\n        s\"Event type '$eventType' does not match $eventTypeRegex.\"\n      )\n    }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/scala/com/twitter/botmaker/runtime/config/ServiceConfigs.scala#L31-L67","documentation":"BotMaker's ServiceConfigs keeps a global registry of unique config name sequences. The unique(names...) helper throws ConfigFailure when the same name sequence (e.g. an eventType, or eventType+endpoint pair) is registered twice, preventing ambiguous duplicate bot/event/endpoint definitions.","triggerScenarios":"Registering two events, endpoints, or configs with the same eventType; or two configs sharing the same (eventType, endpoint) pair — e.g. calling addScheduledEvent twice with the same config.eventType.","commonSituations":"Copy-pasting a config block and forgetting to rename the eventType; a shared config trait mixed into two services registering the same names; redeploying/re-registering configs within the same JVM in tests without resetting ServiceConfigs.","solutions":["Rename one of the conflicting configs so the name sequence is unique (the message concatenates the names, so parse it to find the duplicate)","If registering from a shared trait, parameterize the eventType so each service injects its own name","In tests, reset/clear the ServiceConfigs uniqueNames registry between test cases"],"exampleFix":"// before\naddScheduledEvent(ScheduledEventConfig(eventType = \"ContentScan\", ...))\naddScheduledEvent(ScheduledEventConfig(eventType = \"ContentScan\", ...)) // duplicate\n\n// after\naddScheduledEvent(ScheduledEventConfig(eventType = \"ContentScan\", ...))\naddScheduledEvent(ScheduledEventConfig(eventType = \"ContentScanNightly\", ...))","handlingStrategy":"validation","validationCode":"seen = set()\ndef register(name_seq):\n    key = tuple(name_seq)\n    if key in seen: raise ValueError(f\"duplicate config name {key}\")\n    seen.add(key); unique(*name_seq)","typeGuard":null,"tryCatchPattern":"try:\n    addScheduledEvent(cfg)\nexcept ConfigFailure as e:\n    if str(e).startswith(\"Conflict config name:\"):\n        cfg = cfg.copy(eventType=cfg.eventType + \"2\"); addScheduledEvent(cfg)\n    else:\n        raise","preventionTips":["Derive event names from a single namespaced helper","Reset ServiceConfigs registries between tests"],"tags":["botmaker","scala","duplicate-config","config-validation"],"backgroundTag":"duplicate-resource-registration","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}