JSON errors

Every error message that JSON commands return in Redis 8.10

These are the error messages of the JSON commands, such as JSON.SET and JSON.GET. Many start with ERR, and some start with WRONGTYPE. Others have no code at all.

ERR

Most JSON errors start with the general prefix ERR. Many of them say that a path doesn't exist, or that the value at the path isn't the type that the command needs, as in ERR Path does not exist or not an array. To fix it, check the path. To see the type of the value at a path, run JSON.TYPE.

Error messageExplanationReturned by
ERR <json-parse-error> The value you passed isn't valid JSON: the number for JSON.NUMINCRBY, JSON.NUMMULTBY, or JSON.NUMPOWBY, the value to find with JSON.ARRINDEX, or the string for JSON.STRAPPEND. The message gives the line and column. A string needs double quotes inside the argument, such as '"text"'. JSON.ARRINDEXJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.STRAPPEND
ERR array index out of range The path ends with an array index past the end of the array, and JSON.SET, JSON.MERGE, and JSON.MSET can't add elements to an array. Use an index that exists to replace an element, or add elements with JSON.ARRAPPEND or JSON.ARRINSERT. JSON.SETJSON.MERGEJSON.MSET
ERR bad object type You used JSON.MERGE or JSON.CLEAR on one element of an array that holds only numbers. Redis stores such arrays in a compact form, and these two commands can't change their elements one at a time. Replace the element with JSON.SET, or target the whole array. JSON.MERGEJSON.CLEAR
ERR computed/projection expressions are only supported by JSON.GET/JSON.MGET/JSON.RESP The path is a computed expression, such as $.price * 2 or $.items.length(), not a path to a value. Only JSON.GET, JSON.MGET, and JSON.RESP can evaluate expressions. Other commands need a plain path, such as $.price. JSON.SETJSON.MERGEJSON.MSET
and 18 moreJSON.DELJSON.FORGETJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.ARRAPPENDJSON.ARRINSERTJSON.ARRPOPJSON.ARRTRIMJSON.CLEARJSON.TYPEJSON.STRLENJSON.ARRINDEXJSON.ARRLENJSON.OBJKEYSJSON.OBJLEN
ERR could not perform this operation on a key that doesn't exist The key doesn't exist, and the command works only on a path inside an existing JSON document. Check the key name, or create the document first with JSON.SET on the root path $. JSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBY
and 10 moreJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.CLEAR
ERR FORMAT argument is not supported on RESP2 The FORMAT option of JSON.GET and JSON.ARRPOP works only on connections that use version 3 of the Redis serialization protocol (RESP3). Switch the connection to it with HELLO 3, or remove FORMAT. JSON.GETJSON.ARRPOP
ERR index out of bounds The index you passed to JSON.ARRINSERT is outside the array. For an array of 5 elements, valid indexes are -5 through 5: 5 inserts at the end, and negative values count from the end. Check the length with JSON.ARRLEN. JSON.ARRINSERT
ERR invalid FPHA type The FPHA option of JSON.SET sets the number type for arrays that hold only floating-point numbers, and the type you gave isn't one Redis supports. Use BF16, FP16, FP32, or FP64; letter case doesn't matter. JSON.SET
ERR new objects must be created at the root The key doesn't exist, and you tried to set a value at a path inside it. Create the document first by setting the root path $, then set or merge values at deeper paths. JSON.SETJSON.MERGEJSON.MSET
ERR numeric overflow The result of JSON.NUMINCRBY, JSON.NUMMULTBY, or JSON.NUMPOWBY doesn't fit: an integer beyond the 64-bit range, or a decimal that reaches infinity in an array that holds only numbers. JSON.NUMPOWBY also returns it for a negative integer exponent on an integer; write the exponent as -1.0 instead. JSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBY
ERR Path does not exist The path matches nothing in the document. You get this error when the path doesn't start with $; with a $ path, these commands return an empty array or nil instead. JSON.ARRINDEX also returns it when the key doesn't exist. Check the key and the path. JSON.GETJSON.ARRINDEXJSON.ARRLEN
and 3 moreJSON.STRLENJSON.RESPJSON.CLEAR
ERR Path does not exist or does not contains a number The path matches nothing in the document, or the value there isn't a number. You get this error when the path doesn't start with $; with a $ path, the reply has nil for each match that isn't a number. Check the value's type with JSON.TYPE. JSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBY
ERR Path does not exist or not a bool The path matches nothing, or the value there isn't true or false, the only values JSON.TOGGLE can flip. You get this error when the path doesn't start with $; with a $ path, the reply has nil for each match that isn't a boolean. JSON.TOGGLE
ERR Path does not exist or not a string JSON.STRAPPEND found no string at the path: the path matches nothing, or the value there is another type. You get this error when the path doesn't start with $; with a $ path, the reply has nil for each match that isn't a string. JSON.STRAPPEND
ERR Path does not exist or not an array The command needs an array at the path, but the path matches nothing or the value there is another type. You get this error when the path doesn't start with $; with a $ path, the reply has nil for each match that isn't an array. JSON.ARRAPPENDJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIM
ERR Path does not exist or not an object JSON.OBJKEYS found a value that isn't an object at a path that doesn't start with $. JSON.OBJLEN returns this error when the key doesn't exist and the path starts with $. Check the key name, and check the value's type with JSON.TYPE. JSON.OBJKEYSJSON.OBJLEN
ERR recursion limit exceeded The value you're adding would make the document nest 128 levels or deeper, which is the limit. JSON.ARRAPPEND, JSON.ARRINSERT, and JSON.MERGE add the depth of the target path to the depth of the new value. Flatten the value, or add it at a shallower path. JSON.ARRAPPENDJSON.ARRINSERTJSON.MERGE
ERR result is not a number The result is infinity or not a valid number, which JSON can't store. For example, a product passes about 1.8e308, or JSON.NUMPOWBY raises a negative number to a fractional power. Check the stored value and the number you passed. JSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBY
ERR syntax error JSON.SET or JSON.MERGE got an argument after the value that it doesn't accept. JSON.SET takes one of NX or XX, plus FPHA and FORMAT; JSON.MERGE takes only FORMAT. Also check that a JSON value containing spaces is quoted as one argument. How to fix it JSON.SETJSON.MERGE
ERR wrong format The value after FORMAT in JSON.SET or JSON.MERGE isn't one Redis accepts. Use JSON, STRING, or BSON, in uppercase: these values are case-sensitive. JSON.SETJSON.MERGE
ERR wrong number of arguments for '<command>' command You called the command in the message, shown in lowercase, with too few or too many arguments. Check its syntax: for example, JSON.MSET takes a key, a path, and a value for each document, and JSON.CLEAR takes a key and an optional path. How to fix it JSON.GETJSON.SETJSON.MERGE
and 21 moreJSON.MSETJSON.MGETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
ERR wrong reply format The value after FORMAT isn't valid for this command. JSON.GET accepts STRING, EXPAND1, and EXPAND, and JSON.ARRPOP accepts STRINGS, EXPAND1, and EXPAND. The values are case-sensitive, so write them in uppercase. JSON.GETJSON.ARRPOP

Err

Two errors start with Err, not ERR. Client libraries that compare codes exactly treat Err as a different code. You get these errors when JSON.SET, JSON.MERGE, or JSON.MSET adds a new value at a path that doesn't exist yet. A path that adds a value can't contain wildcards or filters, and it must end with an object key, such as $.address.city. To fix it, change the path to meet these rules.

Error messageExplanationReturned by
Err path must end with object key to set You called JSON.SET with NX and a path that means the whole document but isn't written as $ or ., such as ($). A path that adds a value must end with an object key, such as $.name. For the whole document, use $. JSON.SET
Err wrong static path The path matched nothing, so the command tried to add a value, but the path can match more than one place: it has a wildcard, .., a filter, a slice, or a list of keys or indexes. To add a value, use a path to one location, such as $.address.city. JSON.SETJSON.MERGEJSON.MSET

WRONGTYPE

The value at the path has a different JSON type than the command needs. For example, JSON.STRAPPEND needs a string, and JSON.ARRINDEX needs an array. The message names the type that the command expected. To fix it, check the type of the value with JSON.TYPE, and use a command for that type.

These errors are about the value inside the JSON document. When the key itself holds a different data type, JSON commands return Existing key has wrong Redis type instead.

Error messageExplanationReturned by
WRONGTYPE wrong type of path value - expected array JSON.ARRINDEX found a value at the path that isn't an array. You get this error when the path doesn't start with $; with a $ path, the reply has nil for that match instead. Check the type with JSON.TYPE. JSON.ARRINDEX
WRONGTYPE wrong type of path value - expected bool The value at the path isn't true or false, the only values JSON.TOGGLE can flip. In Redis 8.10, JSON.TOGGLE usually reports this as ERR Path does not exist or not a bool, or as nil in the reply. Check the type with JSON.TYPE. JSON.TOGGLE
WRONGTYPE wrong type of path value - expected object JSON.OBJLEN found a value at the path that isn't an object. You get this error when the path doesn't start with $; with a $ path, the reply has nil for that match instead. Check the type with JSON.TYPE. JSON.OBJLEN
WRONGTYPE wrong type of path value - expected string For JSON.STRLEN, the value at the path isn't a string; you get this error when the path doesn't start with $. For JSON.STRAPPEND, the value you're appending isn't a JSON string: put it in double quotes, such as '"abc"'. JSON.STRLENJSON.STRAPPEND

Messages without a code

These messages have no code. Client libraries and the error statistics of INFO errorstats treat the first word of the message as the code. They include three common kinds of errors:

  • Existing key has wrong Redis type means that the key holds a different data type, not a JSON document. See WRONGTYPE.
  • An error in a path, such as $.a[0, starts with Error occurred at position, followed by what the path parser expected.
  • An error in the JSON value that you send includes the JSON parser's description, such as expected value at line 1 column 1.
Error messageExplanationReturned by
<bson-parse-error> You used FORMAT BSON with JSON.SET or JSON.MERGE, and the value isn't a valid binary JSON (BSON) document. The message is the BSON parser's description of the problem. Send a complete, correctly encoded BSON document, or drop FORMAT BSON and send JSON text. JSON.SETJSON.MERGE
<json-parse-error> The value you sent isn't valid JSON, and the message says what's wrong and where, by line and column. Often a string is missing its double quotes: send '"text"', not text. A value nested 128 levels or deeper fails with recursion limit exceeded. JSON.SETJSON.MERGEJSON.MSETJSON.ARRAPPENDJSON.ARRINSERT
bad input number The number you passed to JSON.NUMINCRBY, JSON.NUMMULTBY, or JSON.NUMPOWBY is valid JSON but not a number, for example a quoted string such as "5" or an array. Pass a plain number, such as 5 or -1.5. JSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBY
Couldn't parse as integer An argument that must be an integer isn't one: the index of JSON.ARRINSERT, the start and stop of JSON.ARRTRIM, or the optional start and stop of JSON.ARRINDEX. Pass whole numbers, such as 0 or -1; negative values count from the end of the array. JSON.ARRINDEXJSON.ARRINSERTJSON.ARRTRIM
Couldn't parse as UTF-8 string An argument, such as a path, a JSON value, or an option, contains bytes that aren't valid UTF-8 text, and JSON commands accept only text there. Make sure your client sends text, and encode binary data, for example as Base64, before you store it. JSON.GETJSON.SETJSON.MERGE
and 21 moreJSON.MSETJSON.MGETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position 0, internal: empty JSONPath parse result This is an internal error in the JSONPath parser: it accepted the path but produced no result, which shouldn't happen for any path. If you get it, report it as a bug, with the path you used. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position 0, internal: JSONPath parse missing EOI This is an internal error in the JSONPath parser: it accepted the path but didn't find its end, which shouldn't happen for any path. If you get it, report it as a bug, with the path you used. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position 0, JSONPath nesting too deep (max depth 128) The path nests brackets and parentheses more than 128 levels deep. Redis counts every [ and ( that isn't inside a quoted string. Rewrite the path with fewer nested levels. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position <position>, Error at position <position>: expected one of the following: <expected-tokens> The path has a syntax error, such as an unclosed bracket or a trailing dot. The position, counted from 0, is where the parser stopped, and the list shows what it expected there. For a path that doesn't start with $, the position includes the $ or $. that Redis adds. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position <position>, Error at position <position>: expected one of the following: <expected-tokens>, unexpected tokens found: <unexpected-tokens> The path has a syntax error at the position shown, counted from 0. The message lists what the parser expected there and what it found instead. For a path that doesn't start with $, the position includes the $ or $. that Redis adds. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position <position>, Error at position <position>: parsing error The path has a syntax error at the position shown, counted from 0, and the parser gives no more detail. Check the path near that position, for example for an unclosed bracket or quote. For a path that doesn't start with $, the position includes the $. that Redis adds. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Error occurred at position <position>, Error at position <position>: unexpected tokens found: <unexpected-tokens> The path has a syntax error: at the position shown, counted from 0, the parser found something that isn't allowed, and the message lists it. For a path that doesn't start with $, the position includes the $ or $. that Redis adds. JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
Existing key has wrong Redis type The key holds another data type, such as a string or a hash, not a JSON document. JSON commands, including JSON.SET, don't replace it. Check the type with TYPE, then use a different key, or delete the key first if you mean to overwrite it. How to fix it JSON.GETJSON.SETJSON.MERGE
and 20 moreJSON.MSETJSON.DELJSON.FORGETJSON.TYPEJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.STRLENJSON.ARRAPPENDJSON.ARRINDEXJSON.ARRINSERTJSON.ARRLENJSON.ARRPOPJSON.ARRTRIMJSON.OBJKEYSJSON.OBJLENJSON.CLEARJSON.RESP
failed notify key space event The command changed the document, but Redis refused to send the keyspace notification for it, so it returned an error. Commands from clients don't get this. Another module can cause it by running the command from a callback that can't send notifications; report it to that module's developers. JSON.SETJSON.MERGEJSON.MSET
and 12 moreJSON.DELJSON.FORGETJSON.NUMINCRBYJSON.NUMMULTBYJSON.NUMPOWBYJSON.TOGGLEJSON.STRAPPENDJSON.ARRAPPENDJSON.ARRINSERTJSON.ARRPOPJSON.ARRTRIMJSON.CLEAR
Legacy paths are supported only with FORMAT STRINGS You called JSON.ARRPOP with FORMAT EXPAND or FORMAT EXPAND1 and a path that doesn't start with $. These formats work only with paths that start with $, such as $.items. Change the path, or remove FORMAT. JSON.ARRPOP
RATE THIS PAGE
Back to top ↑