xai-org/x-algorithm · error · IllegalArgumentException
--$preferred (or deprecated --$deprecated) must be an intege
Error message
--$preferred (or deprecated --$deprecated) must be an integer; got '$s'
What it means
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.
Source
Thrown at under-the-hood/scalding/UnderTheHoodCommon.scala:128
def parseUserIds(args: Args): Set[Long] = {
val raw = args.list("userIds").flatMap(_.split(",")).map(_.trim).filter(_.nonEmpty)
val invalid = raw.filter(s => Try(s.toLong).isFailure)
require(
invalid.isEmpty,
s"--userIds supplied but contains non-numeric ids: ${invalid.mkString(", ")}. " +
"Omit --userIds entirely for an all-user run."
)
raw.flatMap(s => Try(s.toLong).toOption).toSet
}
def preferredInt(args: Args, preferred: String, deprecated: String, default: Int): Int = {
val raw = args.optional(preferred).orElse(args.optional(deprecated))
raw match {
case None => default
case Some(s) =>
Try(s.toInt).getOrElse {
throw new IllegalArgumentException(
s"--$preferred (or deprecated --$deprecated) must be an integer; got '$s'")
}
}
}
def inScope(testUserIds: Set[Long], userId: Long): Boolean =
testUserIds.isEmpty || testUserIds.contains(userId)
def applyReducers[K, V](g: Grouped[K, V], reducers: Int): Grouped[K, V] =
if (reducers > 0) g.withReducers(reducers) else g
}
View on GitHub (pinned to 24c60942c5)
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
Example fix
# before hadoop jar job.jar com.twitter.uth.Job --topUsers 10x # after hadoop jar job.jar com.twitter.uth.Job --topUsers 10
Defensive patterns
Strategy: validation
Validate before calling
val raw = args.optional("topUsers")
raw.foreach(s => require(Try(s.trim.toInt).isSuccess, s"not an int: $s")) Type guard
def isIntArg(s: String): Boolean = Try(s.trim.toInt).isSuccess
Try / catch
try preferredInt(args, "n", "num", 10) catch { case _: IllegalArgumentException => 10 } Prevention
- Validate numeric args in job launch scripts before submitting
- Centralize arg parsing helpers and use them consistently
- Dry-run jobs before production scheduling
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Argument [--entity-type] must be provided. Supported options
- Input user_states $str is invalid. Valid states are: " + Use
- Must read at least some data!
- Adhoc runs require a window: pass --date START END or --mont
- (ScoreType, Entity) ($scoreType, ${entity.toString}) not sup
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/6c1b37a2f3591173.
Report an issue: GitHub.