ErrLookup › Background articles › "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained
"invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained
"unknown update mode", "invalid period", "Unsupported method", "Invalid value for argument `output_mode`" — these are all variants of the invalid-enum-argument error family: a library raises ArgumentError, ValueError, or NotImplementedError because a string, symbol, or integer parameter must be one of a small closed set of values and the caller passed something outside it. Developers hit this when a typo, wrong casing, a string instead of a symbol, a synonym from another library's vocabulary, or a version mismatch sends an unrecognized value into a lookup that has no fallback.
Distilled from 89 documented records across 19 repositories.
Background
These errors come from the simplest defensive pattern in library code: a function that takes an option like mode, method, period, kind, or side looks it up in a fixed table or an if/elif chain, and if the key is missing, control reaches an else branch that raises. Because the parameter space is closed and enumerable, the library treats any other value as a caller bug rather than something it can recover from. The error is raised eagerly at the API boundary — a constructor in Keras layers, an argument check in a Faker generator, a primitive builder in JAX — so the failure happens at call time, not deep inside computation.
The failure modes cluster into a few recognizable groups. Type confusion is one: several libraries dispatch on symbols or enum members, so a plain string fails a hash-key comparison — ruby/ruby's mkdepend only recognizes the symbols :output, :stdout, :inplace, :check, faker-ruby/faker's TIME_RANGES lookup rejects 'morning' while accepting :morning, and fluentd's server helper only accepts the symbols :tcp, :udp, :tls, :unix. Case sensitivity is another: Faker normalizes some inputs with downcase or to_sym but still rejects 'Male' for danish_id_number's gender, JAX rejects mode='HIGH' for gumbel and side='LEFT' for searchsorted, and TradingAgents-CN requires exactly 'ema', 'sma', or 'china' in lowercase.
A third group is vocabulary drift: the caller uses a name that is valid in a neighboring library or an older version. Keras's RandomElasticTransform rejects fill_mode='replicate' and 'edge' because those are OpenCV and Pillow names, not Keras's; Faker::Stripe requires camelCase Stripe decline codes like 'addressZipFail', so snake_case guesses fail; jnp.linalg.vector_norm rejects ord='inf' even though NumPy users write string spellings, because JAX expects the float jnp.inf; and JAX's lu_solve wants trans as 0, 1, or 2, not SciPy's 'T'. Version skew between client and server or JS and wasm produces the same effect at the binary level — Hadoop throws 'Unknown OpenFileType' when a client's enum set matches no branch on the NameNode, and Flow's hermesParse rejects source_type values a newer JS bridge sends to an older wasm binary.
How much help you get varies by library. Some messages enumerate the accepted values — SGLang's "weight_prefix must be 'w13' or 'w2'", TradingAgents-CN's list of RSI methods, Keras's expected-output-mode set — while others just name the offending value, as in faker's "invalid period" or fluentd's terse "BUG: invalid protocol name". Some accepted sets are also locale- or version-dependent: which connection names Faker::Relationship.familial accepts depends on the loaded locale data, and which card types Faker::Stripe recognizes depends on the bundled YAML, so the reliable source of truth is the error message itself or the library's constant/locale keys, not a list copied from documentation.
Common causes
- Typo or misspelling. The most common trigger across the records: :morn instead of :morning, side='rigth', fill_mode='constnat', 'onehot' instead of 'one_hot'. Because the value is matched exactly against a fixed set, one wrong character raises.
- Wrong case or casing assumption. Many libraries compare case-sensitively: 'Male' fails for Faker's danish_id_number gender, 'HIGH' fails for jax.random.gumbel, 'Wilder' and 'EMA' fail for the RSI method check. A few normalize input (Faker downcases relationship connections), but behavior is library-specific — check each API.
- String passed where a symbol or enum constant is required. Symbol-dispatching APIs reject strings: ruby/ruby's run(mode: 'stdout') raises, Faker::Time's period lookup rejects 'morning', fluentd rejects proto: 'tcp'. In typed languages the mirror image is passing a raw int cast to an enum, like (SeekOrigin)99 in Turso's SqliteBlob.Seek.
- Synonym from another library's vocabulary. Using names that are valid elsewhere: fill_mode='replicate' (OpenCV) or 'edge' (Pillow) instead of Keras's 'nearest'; ord='inf' instead of jnp.inf; trans='T' (SciPy) instead of 1; 'dawn' instead of Faker's :morning. Each library owns its own vocabulary.
- Value not present in the loaded locale or version. Faker's accepted connections, card types, and decline codes come from locale data and can differ between locales and gem versions, so a value that worked before — or is documented on an external site like Stripe's testing docs — can still be absent from your install's key set.
- Client and server (or JS and wasm) enum skew. Version mismatches produce unrecognized enum values at boundaries: a Hadoop client sending an OpenFilesType set the NameNode doesn't know, or Flow's JS bridge passing a new source_type value to an older wasm binary. Rebuild or pin both sides to the same release.
- Wrong snake_case vs camelCase key form. Faker::Stripe's invalid_card expects Stripe's camelCase decline codes such as 'addressZipFail'; snake_case guesses like 'address_zip_fail' raise even though they look more idiomatic in Ruby.
- nil or empty value forwarded as the argument. Passing nil where an explicit value is required — e.g. Faker::IdNumber.danish_id_number(gender: :nonbinary) or a null WriteMode reaching Hadoop's EventWriter — hits the else branch. Note the inverse is also common: omitting the argument entirely usually picks a safe default and never raises.
What usually fixes it
- Copy the accepted values from the error message itself, not from memory, another library's docs, or an older version — most of these errors enumerate the valid set, and that list is the source of truth for your installed version.
- Match the type the library expects: pass symbols where the library dispatches on symbols (ruby/ruby, Faker::Time, fluentd), enum constants rather than raw ints (Hadoop's WriteMode, Turso's SeekOrigin), and float jnp.inf rather than the string 'inf'.
- Normalize user- or config-supplied values at the boundary before passing them: whitelist against the known set, lowercase and to_sym where appropriate, and map external vocabulary explicitly (e.g. {'N': 0, 'T': 1, 'C': 2}[mode] for lu_solve, OpenCV 'replicate' to Keras 'nearest').
- When a value comes from YAML, CLI flags, or environment config, validate it once at parse/load time against the library's constant — Keras exposes sets like _SUPPORTED_INTERPOLATION and accepted_output_modes, Faker exposes locale keys — so failures surface at startup instead of mid-run.
- For version- or locale-dependent value sets, enumerate them at runtime (I18n keys for Faker, grep the dispatcher branches for SGLang) or pin client and server/package and binary artifacts to the same release so enum definitions cannot drift.
Documented occurrences
- unknown update mode: #{mode.inspect} (ruby/ruby)
- Familial connections can be left blank or #{familial_connections.join(', ')} (faker-ruby/faker)
- invalid period (faker-ruby/faker)
- Invalid order '{ord}' for vector norm. (jax-ml/jax)
- The file upload editor mode must be either 1, 2 or 3. [{$mode}] given, which is unsupported. See https://github.com/fengyuanchen/cropperjs/blob/v1/README.md#viewmode for more information on the available modes. Mode 0 is not supported, as it does not allow configuration via manual inputs. (filamentphp/filament)
- 不支持的RSI计算方法: {method},支持的方法: 'ema', 'sma', 'china' (hsliuping/TradingAgents-CN)
- Unknown mode: ${mode} (apache/hadoop)
- Invalid gender #{gender}. Must be one of male, female, or be omitted. (faker-ruby/faker)
- Invalid credit cards argument can be left blank or include #{invalid_cards.join(', ')} (faker-ruby/faker)
- unknown dependency scope: #{scope} (ruby/ruby)
- Valid credit cards argument can be left blank or include #{valid_cards.join(', ')} (faker-ruby/faker)
- Unknown `interpolation` {interpolation}. Expected of one {self._SUPPORTED_INTERPOLATION}. (keras-team/keras)
- Valid credit cards argument can be left blank or include #{valid_tokens.join(', ')} (faker-ruby/faker)
- Unknown OpenFileType: {} (apache/hadoop)
- Unsupported method: {method} (jax-ml/jax)
- weight_prefix must be 'w13' or 'w2', got '{weight_prefix}' (sgl-project/sglang)
- Invalid value {origin} for enum type {SeekOrigin}. (tursodatabase/turso)
- Unknown `fill_mode` {fill_mode}. Expected of one {self._SUPPORTED_FILL_MODES}. (keras-team/keras)
- hermesParse: invalid source_type={other}; expected 0 (unspecified), 1 (script), or 2 (module). (facebook/flow)
- invalid argument side={side!r}, expected 'left' or 'right' (jax-ml/jax)
…and 69 more across the corpus — use search.
Honest provenance: generated on 2026-08-28 from AI-assisted analysis of the linked records. See how records are made.