Skip to content

Fix json_set() value argument type #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 18, 2025
Merged

Conversation

nafraf
Copy link
Contributor

@nafraf nafraf commented May 17, 2025

Current behavior:
json_set fails trying to set a numeric value:

Example:
In Redis server, create a new json document user:100 with two fields: name, age add random values to them.

GitHub Copilot

Ran json_set - my-mcp-redis-server (MCP Server)

Input

{
  "name": "user:100",
  "path": "$",
  "value": "{\"name\": \"Alice\", \"age\": 27}"
}

Output

Error executing tool json_set: 1 validation error for json_setArguments
value
  Input should be a valid string [type=string_type, input_value={'name': 'Alice', 'age': 27}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/string_type

Change:
The type of json_set value argument is changed to JsonType.
The definition of JsonType is the same used by redis-py

https://github.com/redis/redis-py/blob/36619a507addc313c0245bf318e4678938fc5d44/redis/commands/json/_util.py#L3

@mortensi
Copy link
Member

Thanks a lot @nafraf. Maybe we can also use it directly

from redis.commands.json._util import JsonType

Without redefining it. What do you think?

@nafraf
Copy link
Contributor Author

nafraf commented May 18, 2025

@mortensi You are right! Thanks.

@mortensi mortensi merged commit 34cf856 into redis:main May 18, 2025
@mortensi
Copy link
Member

Thanks to you! Merged

@nafraf nafraf deleted the fix-json-set branch May 19, 2025 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants