{"record":{"id":"6c1b37a2f3591173","repo":"xai-org/x-algorithm","slug":"preferred-or-deprecated-deprecated-must-be","errorCode":null,"errorMessage":"--$preferred (or deprecated --$deprecated) must be an integer; got '$s'","messagePattern":"--\\$preferred \\(or deprecated --\\$deprecated\\) must be an integer; got '\\$s'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"under-the-hood/scalding/UnderTheHoodCommon.scala","lineNumber":128,"sourceCode":"\n  def parseUserIds(args: Args): Set[Long] = {\n    val raw = args.list(\"userIds\").flatMap(_.split(\",\")).map(_.trim).filter(_.nonEmpty)\n    val invalid = raw.filter(s => Try(s.toLong).isFailure)\n    require(\n      invalid.isEmpty,\n      s\"--userIds supplied but contains non-numeric ids: ${invalid.mkString(\", \")}. \" +\n        \"Omit --userIds entirely for an all-user run.\"\n    )\n    raw.flatMap(s => Try(s.toLong).toOption).toSet\n  }\n\n  def preferredInt(args: Args, preferred: String, deprecated: String, default: Int): Int = {\n    val raw = args.optional(preferred).orElse(args.optional(deprecated))\n    raw match {\n      case None => default\n      case Some(s) =>\n        Try(s.toInt).getOrElse {\n          throw new IllegalArgumentException(\n            s\"--$preferred (or deprecated --$deprecated) must be an integer; got '$s'\")\n        }\n    }\n  }\n\n  def inScope(testUserIds: Set[Long], userId: Long): Boolean =\n    testUserIds.isEmpty || testUserIds.contains(userId)\n\n  def applyReducers[K, V](g: Grouped[K, V], reducers: Int): Grouped[K, V] =\n    if (reducers > 0) g.withReducers(reducers) else g\n}\n","sourceCodeStart":110,"sourceCodeEnd":140,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/under-the-hood/scalding/UnderTheHoodCommon.scala#L110-L140","documentation":"UnderTheHoodCommon.preferredInt parses a command-line arg (trying the preferred flag, then a deprecated alias) with s.toInt and throws when parsing fails. It exists to migrate users off a deprecated flag name while accepting either.","triggerScenarios":"Running a scalding job with the preferred flag (or its deprecated alias) set to a non-numeric value like '10x' or '100k'; passing a value with stray characters from shell quoting; a scheduled job template with an unreplaced placeholder.","commonSituations":"Migrating job flags: value supplied to the old deprecated name in a bad format; shell quoting injecting extra characters; cron templates with placeholder text not replaced.","solutions":["Re-run with a plain integer for the preferred (or deprecated) flag, e.g. --preferred 100","Check shell scripts/cron templates for stray characters or unreplaced placeholders in that arg","Drop the flag entirely to accept the documented default","If you intended unit suffixes (k/m), expand them to plain integers"],"exampleFix":"# before\nhadoop jar job.jar com.twitter.uth.Job --topUsers 10x\n# after\nhadoop jar job.jar com.twitter.uth.Job --topUsers 10","handlingStrategy":"validation","validationCode":"val raw = args.optional(\"topUsers\")\nraw.foreach(s => require(Try(s.trim.toInt).isSuccess, s\"not an int: $s\"))","typeGuard":"def isIntArg(s: String): Boolean = Try(s.trim.toInt).isSuccess","tryCatchPattern":"try preferredInt(args, \"n\", \"num\", 10) catch { case _: IllegalArgumentException => 10 }","preventionTips":["Validate numeric args in job launch scripts before submitting","Centralize arg parsing helpers and use them consistently","Dry-run jobs before production scheduling"],"tags":["scala","scalding","cli-args","parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}