{"record":{"id":"ca85f1b5194b32d8","repo":"xai-org/x-algorithm","slug":"input-user-states-str-is-invalid-valid-states-ar","errorCode":null,"errorMessage":"Input user_states $str is invalid. Valid states are: \" + UserState.list","messagePattern":"Input user_states \\$str is invalid\\. Valid states are: \" \\+ UserState\\.list","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"simclusters/simclusters_v2/scalding/evaluation/CandidateEvaluationBase.scala","lineNumber":39,"sourceCode":"    val validStateSet = validStates.toSet\n\n    userStateSource\n      .collect {\n        case data if data.userState.isDefined && validStateSet.contains(data.userState.get) =>\n          (data.userState.get, data.uid)\n      }\n      .filter(_ => Random.nextDouble() <= samplePercentage)\n      .forceToDisk\n  }\n\n  def parseUserStates(strStates: Seq[String]): Seq[UserState] = {\n    if (strStates.isEmpty) {\n      UserState.list\n    } else {\n      strStates.map { str =>\n        UserState\n          .valueOf(str).getOrElse(\n            throw new IllegalArgumentException(\n              s\"Input user_states $str is invalid. Valid states are: \" + UserState.list\n            )\n          )\n      }\n    }\n  }\n}\n\ntrait UserStateBasedEvaluationExecutionBase\n    extends CandidateEvaluationBase\n    with TwitterExecutionApp {\n\n  def referenceTweets: TypedPipe[ReferenceTweets]\n  def candidateTweets: TypedPipe[CandidateTweets]\n\n  override def job: Execution[Unit] = {\n    Execution.withId { implicit uniqueId =>\n      Execution.withArgs { args =>","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/simclusters/simclusters_v2/scalding/evaluation/CandidateEvaluationBase.scala#L21-L57","documentation":"CandidateEvaluationBase parses the user_states argument: each comma/semicolon-separated string must map via UserState.valueOf to a known UserState. Invalid tokens trigger this IllegalArgumentException enumerating the valid states.","triggerScenarios":"Passing a user_states argument containing a token not in UserState (e.g. 'protected', 'suspennded'), while running the evaluation job.","commonSituations":"Typos in state names; states renamed/removed between code versions; copying state lists from another environment's job config.","solutions":["Check UserState.list (in the error message) and correct the token to a valid state name","Trim whitespace and normalize case before comparing against UserState.valueOf","If the state genuinely should exist, add it to the UserState enum in user-text-entity-regex or the owning lib"],"exampleFix":"// before\nstrStates.map { str =>\n  UserState.valueOf(str).getOrElse(\n    throw new IllegalArgumentException(s\"Input user_states $str is invalid. Valid states are: \" + UserState.list))\n}\n\n// after (fail fast with normalized tokens)\nval validStates = UserState.list.map(s => s.toString.toLowerCase).toSet\nval invalid = strStates.filterNot(s => validStates(s.trim.toLowerCase))\nrequire(invalid.isEmpty, s\"Invalid user_states: $invalid. Valid: ${UserState.list}\")","handlingStrategy":"validation","validationCode":"val valid = UserState.list.map(_.toString).toSet\nval invalid = strStates.filterNot(valid)\nrequire(invalid.isEmpty, s\"Invalid user_states $invalid; valid: ${UserState.list}\")","typeGuard":"def isValidUserState(s: String): Boolean = UserState.valueOf(s).isDefined","tryCatchPattern":null,"preventionTips":["Trim and case-normalize tokens before lookup","Pin the job version and re-verify state names after upgrades"],"tags":["scala","scalding","validation","cli-args","evaluation"],"backgroundTag":"invalid-enum-value-in-config","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}