Ratel does not url-encode predicate in move tablet url

When I move a predicate that contains characters not allowed in an URL, Ratel fails to move it. It produces an URL that does not url-encode the predicate, which is thus an invalid URL:

docker run --rm -it -p 6080:6080 -p 8000:8000 -p 8080:8080 dgraph/standalone:v20.03.4 /bin/bash
dgraph zero > /dev/null 2> /dev/null &
dgraph alpha --port_offset 0 --lru_mb 1024 --cwd /dgraph/0 > /dev/null 2> /dev/null &
dgraph alpha --port_offset 1 --lru_mb 1024 --cwd /dgraph/1 > /dev/null 2> /dev/null &
dgraph-ratel > /dev/null 2> /dev/null &

Wait until alpha nodes are up, then

curl "localhost:8080/alter" -XPOST -d $'<http://www.w3.org/2000/01/rdf-schema#label>: string .'

Go to the Ratel UI > Cluster and move the predicate <http://www.w3.org/2000/01/rdf-schema#label>. This will produce URL http://localhost:6080/moveTablet?tablet=http://www.w3.org/2000/01/rdf-schema#label&group=1 which fails with the following error:

The URL should read http://localhost:6080/moveTablet?tablet=http%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label&group=1.

1 Like

Hey @EnricoMi,

Thanks for the very well documented issue. I’ve created a PR to fix your issue here: Use URL encoding with /moveTablet by ajeetdsouza · Pull Request #226 · dgraph-io/ratel · GitHub


Looks good, thanks! Is there a systematic way to search for such kind of urls in that codebase?

@EnricoMi, I did look through quite a few instances in Ratel where URLs were being generated. In all of the other cases I found, an integer is being passed to the URL. Since integers do not need URL encoding, it works fine, but it seems this one slipped through the cracks!

1 Like

Thanks for double-checking. Good work!

1 Like