{"record":{"id":"910cdd9b7af133aa","repo":"xai-org/x-algorithm","slug":"field-name-fieldname-does-not-match-fieldnamer","errorCode":null,"errorMessage":"Field name '$fieldName' does not match $fieldNameRegex.","messagePattern":"Field name '\\$fieldName' does not match \\$fieldNameRegex\\.","errorType":"validation","errorClass":"ConfigFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/scala/com/twitter/botmaker/runtime/config/ServiceConfigs.scala","lineNumber":72,"sourceCode":"  }\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    }\n  }\n\n  def validateFieldName(fieldName: String): Unit = {\n    if (fieldNameRegex.findFirstIn(fieldName).isEmpty) {\n      throw ConfigFailure(\n        s\"Field name '$fieldName' does not match $fieldNameRegex.\"\n      )\n    }\n  }\n\n  def validateFuncName(funcName: String): Unit = {\n    if (funcNameRegex.findFirstIn(funcName).isEmpty) {\n      throw ConfigFailure(\n        s\"Func name '$funcName' does not match $funcNameRegex.\"\n      )\n    }\n  }\n\n  def validateEndpoint(endpoint: String): Unit = {\n    if (endpoint != \"ScribeClient\"\n      && endpointRegex.findFirstIn(endpoint).isEmpty) {\n      throw ConfigFailure(\n        s\"Endpoint '$endpoint' does not match $endpointRegex.\"","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/scala/com/twitter/botmaker/runtime/config/ServiceConfigs.scala#L54-L90","documentation":"Field names in BotMaker configs (struct/dataclass fields passed through the codegen pipeline) must match fieldNameRegex. validateFieldName throws ConfigFailure naming both the field and the regex when the field identifier does not conform.","triggerScenarios":"Defining a config data type whose field name fails fieldNameRegex — e.g. names with hyphens, '$', leading underscores or digits, or reserved punctuation — when the config is registered and validated.","commonSituations":"Mirroring an external JSON/Thrift schema whose keys contain dashes or '@'; Scala keywords or synthetic field names like 'x$1'; fields copied from YAML with odd characters.","solutions":["Rename the field to plain alphanumeric identifier style (typically camelCase)","If the source schema has odd keys, map them to safe Scala identifiers and translate at the serialization boundary","Pre-validate all field names against the same regex in a unit test of your config module"],"exampleFix":"// before\ncase class Rule(match-threshold: Int) // invalid identifier\n\n// after\ncase class Rule(matchThreshold: Int)","handlingStrategy":"type-guard","validationCode":"FIELD_NAME_RE = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$')\nbad = [f for f in dataclass_fields(Cfg) if not FIELD_NAME_RE.match(f.name)]\nassert not bad, bad","typeGuard":"def isValidFieldName(name: str) -> bool:\n    return bool(re.match(r'^[a-zA-Z][a-zA-Z0-9_]*$', name))","tryCatchPattern":null,"preventionTips":["Map external schema keys to safe identifiers at the boundary","Lint config case classes for exotic field names"],"tags":["botmaker","scala","naming-convention","config-validation"],"backgroundTag":"identifier-validation-failed","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}