cursored SpiceDB requests with changing limits
# spicedb
r
Hi guys. I am upgrading spiceDb to v1.24 and I have a question / feedback regarding the cursor feature. I got the error msg " io.grpc.StatusRuntimeException: FAILED_PRECONDITION: the cursor provided does not have the same arguments as the original API call; please ensure you are making the same API call, with the exact same parameters (besides the cursor)" Now this happened because I changed the
optional_limit
Why does optional_limit belong to the validation? I was not expecting such bahviour. 🙂 Thank you
v
Hi Rodolfo 👋 Once you initiate a first paginated call, you get the cursor, and pass it to a subsequent call, the parameters need to be consistent across calls, because they determine how the graph is traversed and may yield unexpected results if changed. Would you mind describing why you'd want to change the page limit as you iterate through pages? cc @Joey
e.g. for a 320 results request, when you iterate, SpiceDB expects this: start -> 100 results -> 100 results -> 100 results -> 20 results (last page)-> end you cannot do this start -> 100 results -> 20 results -> 100 results -> 100 results (last page) -> end
to be clear, the API does not expect you to change the
optional_limit
, it's just telling you that once you start a cursored API call, and get the cursor, any subsequent calls with that cursor (or derivatives) need to have the same parameters
r
So if the first request is for 5 results and the second for 20 because "reasons" (I caught this while testing) Does changing the limit changes the way the graph will be traversed? It is an honest question / I was not expecting. (in the meanwhile I got my answer, but still looks like a bit unnecessary in my head... it is not a big issue though 😆 ) Anyway, I am happy for this feature as it is going to solve some of our problems
v
It's a good question! I'm not 100% sure for the limit itself, but other parameters will surely affect the results. It may be a legitimate use-case to dynamically adjust the limit, hence me asking 😄
What API were you calling? RR is potentially ok, LR may be a bit more complicated
if you think this is a legitimate use-case you'd like to see supported, I'd suggest opening a feature request in the repo 🙏
r
I started by RR.. so the test was quite simple, I picked one cursor and wanted to know if the cursor was inclusive or now. So I asked for 5 results and then "all after the 5th" and it gave me that error. I am not sure if it is "legitimate use-case" but I will ask around and come back. (probably a very minor thing) I was genuinely curious. For now I will document as such 💪
thank you for your reply
v
np, thanks for reporting!
2 Views