{"record":{"id":"73e90bd212061b7b","repo":"stanfordnlp/CoreNLP","slug":"encountered-a-value-without-a-key","errorCode":null,"errorMessage":"Encountered a value without a key","messagePattern":"Encountered a value without a key","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/util/StringUtils.java","lineNumber":2674,"sourceCode":"        } else if(chars[i] == '\\'') {\n          quoteCloseChar = '\\'';\n        } else if (chars[i] == '\\n' && current.length() == 0) {\n          // current.append(\"\");  // do nothing\n        } else if(chars[i] == ',' || chars[i] == ';' || chars[i] == '\\t' || chars[i] == '\\n'){\n          // case: end a value\n          if (onKey) {\n            throw new IllegalArgumentException(\"Encountered key without value\");\n          }\n          if (current.length() > 0) {\n            value = current.toString().trim();\n          }\n          current = new StringBuilder();\n          onKey = true;\n          map.put(key, value);  // <- add value\n        } else if((chars[i] == '-' || chars[i] == '=') && (i < chars.length - 1 && chars[i + 1] == '>')) {\n          // case: end a key\n          if (!onKey) {\n            throw new IllegalArgumentException(\"Encountered a value without a key\");\n          }\n          if (current.length() > 0) {\n            key = current.toString().trim();\n          }\n          current = new StringBuilder();\n          onKey = false;\n          i += 1; // skip '>' character\n        } else if (chars[i] == ':') {\n          // case: end a key\n          if (!onKey) {\n            throw new IllegalArgumentException(\"Encountered a value without a key\");\n          }\n          if (current.length() > 0) {\n            key = current.toString().trim();\n          }\n          current = new StringBuilder();\n          onKey = false;\n        } else {","sourceCodeStart":2656,"sourceCodeEnd":2692,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/util/StringUtils.java#L2656-L2692","documentation":"In the encoded-map automaton, the '->' token ends a key. If '->' is encountered while a value is being parsed (onKey == false), the string contains a second key/value delimiter inside a value, meaning a value was never properly terminated — the decoder throws IllegalArgumentException.","triggerScenarios":"Passing a map string like \"(a->b->c)\" where a value contains an unescaped '->'; or a value containing '=>' at the wrong state.","commonSituations":"Values that legitimately contain '->' (arrows in text, lambda descriptions) without quoting/escaping; concatenated map strings; copy-paste merging two entries.","solutions":["Escape or quote the '->' inside the value if supported, or remove it","Use a different separator syntax (e.g. 'k:v') for values containing '->'","Sanitize values to strip or replace '->' before encoding","Catch IllegalArgumentException and pinpoint the offending segment"],"exampleFix":"// before\nStringUtils.decodeMap(\"(a->b->c)\");\n// after\nStringUtils.decodeMap(\"(a->b arrow c)\");","handlingStrategy":"validation","validationCode":"for (String entry : body.split(\",\")) { int idx = entry.indexOf(\"->\"); if (idx != entry.lastIndexOf(\"->\")) throw new IllegalArgumentException(\"Value contains '->': \" + entry); }","typeGuard":null,"tryCatchPattern":"try { map = StringUtils.decodeMap(encoded); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"value without a key\")) { /* sanitize '->' in values */ } throw e; }","preventionTips":["Never include raw '->' inside values; escape or rephrase","Use ':' delimiters when values contain arrows","Sanitize values before encoding into the map string"],"tags":["java","map-parsing","malformed-input","syntax-error"],"backgroundTag":"invalid-argument-format","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}