OPA 1.0.0 get document REST API is broken when path contains backslash.
Short description
OPA 1.0.0 get document API is broken when path contains backslash character.
curl -XGET 'http://localhost:8181/v1/data/some/path/pa%5Cpa/test2' # backslash character URL encoded to %5C
{
"code": "internal_error",
"message": "2 errors occurred:\n1:19: rego_parse_error: illegal escape sequence\n\tdata[\"some\"].path[\"pa\\pa\"].test2\n\t ^\n1:19: rego_parse_error: illegal token\n\tdata[\"some\"].path[\"pa\\pa\"].test2\n\t ^"
}
Steps To Reproduce
# Running OPA 1.0.0
./opa_darwin_arm64_static_1.0.0 run -s 2>> opa.log &
# Put a document where the path contains backslash character (backslash character URL encoded to %5C)
curl -XPUT 'http://localhost:8181/v1/data/some/path/pa%5Cpa/test2' -d'{"key": "value"}'
# Getting the inserted document
curl -XGET 'http://localhost:8181/v1/data/some/path/pa%5Cpa/test2'
{
"code": "internal_error",
"message": "2 errors occurred:\n1:19: rego_parse_error: illegal escape sequence\n\tdata[\"some\"].path[\"pa\\pa\"].test2\n\t ^\n1:19: rego_parse_error: illegal token\n\tdata[\"some\"].path[\"pa\\pa\"].test2\n\t ^"
}
Expected behavior
This behaves as expected in OPA 0.70.0
# Running OPA 0.70.0
./opa_darwin_arm64_static_0.70.0 run -s 2>> opa.log &
# Put a document where the path contains backslash character (backslash character URL encoded to %5C)
curl -XPUT 'http://localhost:8181/v1/data/some/path/pa%5Cpa/test2' -d'{"key": "value"}'
# Getting the inserted document
curl -XGET 'http://localhost:8181/v1/data/some/path/pa%5Cpa/test2'
{"result":{"key":"value"}}
Additional context
Looks like in 1.0.0 GET API is expecting the path to be quoted in JSON, whereas the PUT is working as before.
# Running OPA 1.0.0
./opa_darwin_arm64_static_1.0.0 run -s 2>> opa.log &
# Put a document where the path contains backslash character (backslash character URL encoded to %5C)
curl -XPUT 'http://localhost:8181/v1/data/some/path/pa%5Cpa/test2' -d'{"key": "value"}'
# Getting the inserted document (NOTE the double backslashes URL encoded as %5C%5C)
curl -XGET 'http://localhost:8181/v1/data/some/path/pa%5C%5Cpa/test2'
{"result":{"key":"value"}}
I will check the bug
Interesting. I don't recall us having made any changes in that code recently. I wonder if it could be some dependency that changed? Oh well, I guess we'll find out eventually. Thanks for reporting it!
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.