stanfordnlp/CoreNLP · error · IllegalArgumentException
Unclosed bracke in encoded array: " + encoded
Error message
Unclosed bracke in encoded array: " + encoded
What it means
Same decoder path for '{'-delimited encoded arrays. If the string starts with '{' the last character must be '}' (note the typo 'bracke' in the message). Otherwise the encoded array is malformed and an IllegalArgumentException is thrown.
Solutions
- Append the matching '}' as the final character of the encoded string
- Fix the code that builds the encoded string to emit a matching closing brace
- Normalize/validate delimiters before decoding
- Catch IllegalArgumentException and surface a clear parse failure
Example fix
// before
StringUtils.decode("{foo,bar");
// after
StringUtils.decode("{foo,bar}"); Defensive patterns
Strategy: validation
Validate before calling
if (s != null && s.startsWith("{") && !s.endsWith("}")) throw new IllegalArgumentException("Encoded array must end with '}': " + s); Type guard
static boolean isBraceBalanced(String s) { return s != null && s.length() >= 2 && s.charAt(0)=='{' && s.charAt(s.length()-1)=='}'; } Prevention
- Use one delimiter style consistently in generators and configs
- Validate brace balance before calling the decoder
- Beware copy-paste truncation of encoded values
When it happens
Trigger: Calling the public StringUtils decode method with a string whose first character is '{' but whose last character is not '}' (e.g. "{a,b", "{a,b]").
Common situations: Mixing up brace styles when writing encoded values by hand; a generator that emits '{' but a different closer; truncation during copy-paste or serialization.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Unclosed bracket in encoded array: " + encoded
- Last character of encoded array is escape character: " +…
- Unclosed bracket in encoded map: " + encoded
- Unclosed paren in encoded map: " + encoded
- Cannot find matching labelled span for
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/15da41a3b70cf62f.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/util/StringUtils.java:2567
* or parentheses.
*
* @param encoded The String encoding an array
* @return A String array corresponding to the encoded array
*/
public static String[] decodeArray(String encoded) {
if (encoded.isEmpty()) return EMPTY_STRING_ARRAY;
char[] chars = encoded.trim().toCharArray();
//--Parse the String
// (state)
char quoteCloseChar = (char) 0;
List<String> terms = new ArrayList<>();
StringBuilder current = new StringBuilder();
//(start/stop overhead)
int start = 0; int end = chars.length;
if(chars[0] == '('){ start += 1; end -= 1; if(chars[end] != ')') throw new IllegalArgumentException("Unclosed paren in encoded array: " + encoded); }
if(chars[0] == '['){ start += 1; end -= 1; if(chars[end] != ']') throw new IllegalArgumentException("Unclosed bracket in encoded array: " + encoded); }
if(chars[0] == '{'){ start += 1; end -= 1; if(chars[end] != '}') throw new IllegalArgumentException("Unclosed bracke in encoded array: " + encoded); }
// (finite state automaton)
for (int i=start; i<end; i++) {
if (chars[i] == '\r') {
// Ignore funny windows carriage return
continue;
} else if (quoteCloseChar != 0) {
//(case: in quotes)
if(chars[i] == quoteCloseChar){
quoteCloseChar = (char) 0;
}else{
current.append(chars[i]);
}
} else if(chars[i] == '\\'){
//(case: escaped character)
if(i == chars.length - 1) throw new IllegalArgumentException("Last character of encoded array is escape character: " + encoded);
current.append(chars[i+1]);
i += 1;
} else {View on GitHub (pinned to 1b7edd19c4)