{"record":{"id":"2a9fd2f93c26dec4","repo":"stanfordnlp/CoreNLP","slug":"spanishlexer-invalid-option-value-in-constructor","errorCode":null,"errorMessage":"SpanishLexer: Invalid option value in constructor: ${key}: ${value}","messagePattern":"SpanishLexer: Invalid option value in constructor: (.+?): (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/international/spanish/process/SpanishLexer.java","lineNumber":14183,"sourceCode":"                untokenizable = UntokenizableOptions.NONE_DELETE;\n                break;\n              case \"firstDelete\":\n                untokenizable = UntokenizableOptions.FIRST_DELETE;\n                break;\n              case \"allDelete\":\n                untokenizable = UntokenizableOptions.ALL_DELETE;\n                break;\n              case \"noneKeep\":\n                untokenizable = UntokenizableOptions.NONE_KEEP;\n                break;\n              case \"firstKeep\":\n                untokenizable = UntokenizableOptions.FIRST_KEEP;\n                break;\n              case \"allKeep\":\n                untokenizable = UntokenizableOptions.ALL_KEEP;\n                break;\n              default:\n                throw new IllegalArgumentException(\"SpanishLexer: Invalid option value in constructor: \" + key + \": \" + value);\n            }\n          } else if (\"strictTreebank3\".equals(key)) {\n            strictTreebank3 = val;\n          } else {\n            throw new IllegalArgumentException(String.format(\"%s: Invalid options key in constructor: %s%n\", this.getClass().getName(), key));\n          }\n        }\n        // this.seenUntokenizableCharacter = false; // unnecessary, it's default initialized\n        if (invertible) {\n          if ( ! (tf instanceof CoreLabelTokenFactory)) {\n            throw new IllegalArgumentException(\"SpanishLexer: the invertible option requires a CoreLabelTokenFactory\");\n          }\n          prevWord = (CoreLabel) tf.makeToken(\"\", 0, 0);\n          prevWordAfter = new StringBuilder();\n        }\n      }\n\n","sourceCodeStart":14165,"sourceCodeEnd":14201,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/international/spanish/process/SpanishLexer.java#L14165-L14201","documentation":"This is the fall-through error in SpanishLexer's option-handling switch: any 'untokenizable' value outside the recognized UntokenizableOptions names (e.g. noneDelete, firstKeep, allKeep, etc.) is rejected. The message includes both the option key and the offending value, distinguishing it from the separate unknown-key error.","triggerScenarios":"Constructing SpanishLexer with 'untokenizable=<badValue>', e.g. 'untokenizable=keep-all', 'untokenizable=none', an empty value, or a value with unexpected casing/whitespace beyond trim.","commonSituations":"Config copied from PTBTokenizer docs but with altered enum names; typos in properties files; programmatic option string built by concatenation producing empty or doubled values; version drift where an option alias was removed.","solutions":["Use one of the exact UntokenizableOptions values: noneDelete, noneKeep, noneThrow, firstDelete, firstKeep, firstThrow, allDelete, allKeep, allThrow (as defined in the switch).","Verify the untokenizable value casing — the switch matches exact strings like 'allKeep', not all-lowercase.","Normalize/validate the option string before constructing the lexer.","Catch IllegalArgumentException during lexer construction to report the bad key/value pair to users."],"exampleFix":"// before\nnew SpanishLexer(reader, \"untokenizable=keep-all\");\n// after\nnew SpanishLexer(reader, \"untokenizable=allKeep\");","handlingStrategy":"validation","validationCode":"java.util.Set<String> valid = java.util.Set.of(\"noneDelete\",\"noneKeep\",\"noneThrow\",\n    \"firstDelete\",\"firstKeep\",\"firstThrow\",\"allDelete\",\"allKeep\",\"allThrow\");\nString v = value.trim();\nif (!valid.contains(v)) throw new IllegalArgumentException(\"Bad untokenizable option: \" + v);","typeGuard":"static boolean isValidUntokenizable(String value) {\n  if (value == null) return false;\n  switch (value.trim()) {\n    case \"noneDelete\": case \"noneKeep\": case \"noneThrow\":\n    case \"firstDelete\": case \"firstKeep\": case \"firstThrow\":\n    case \"allDelete\": case \"allKeep\": case \"allThrow\":\n      return true;\n    default:\n      return false;\n  }\n}","tryCatchPattern":"try {\n  lexer = new SpanishLexer(reader, options);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Invalid option value in constructor\")) {\n    // log key/value, apply safe default\n    lexer = new SpanishLexer(reader, options.replaceAll(\"untokenizable=[^,]*\", \"untokenizable=noneDelete\"));\n  } else { throw e; }\n}","preventionTips":["Use the exact camelCase option values (e.g. allKeep) — the switch is case-sensitive.","Parse the options string into key/value pairs before passing it to the lexer.","Add a unit test constructing the lexer with every documented option value.","Log key and value when construction fails to speed up config debugging."],"tags":["java","stanford-nlp","tokenizer","configuration","lexer"],"backgroundTag":"invalid-config-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}