You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception when calling SortedSetRemoveAsync on IDatabase with empty values array #1972
I'm getting an exception (ERR wrong number of arguments for 'zrem' command) when calling database.SortedSetRemoveAsync(setKey, values) where "values" is empty array.
As a result the same call within a transaction also throws an exception, but with less descriptive message (EXECABORT Transaction discarded because of previous errors.)
It seems like such command might be considered as always successful.
Methods which are not marked with (*) will throw ERR wrong number of arguments for 'COMMANDNAME' command.
Methods which are marked with (*) have explicit throw new ArgumentOutOfRangeException(...) for empty collections, so they differ from the others.
However, I think that they can be converted to act as no-op to be consistent with other methods which handle empty arrays gracefully. At least it doesn't make sense to throw ArgumentOutOfRangeException, because there's no range. It should have been just ArgumentException. I understand that it's not always possible not to throw exceptions (or throw exception of another type) because of compatibility reasons. Just thoughts.
I have some large PRs in pipe around normalizing docs and such, so this would wait until after, but I think it's reasonable to put a similar check in here for .Length == 0 => default like we do in other places. That should be a net win without breaking anyone. Thoughts?
Activity
hankovich commentedon Jan 31, 2022
I've inspected all IDatabase's methods and found several which don't handle empty collections gracefully (i.e. will throw).
Here's the complete list (and don't forget about all
Asyncversions):Methods which are not marked with
(*)will throwERR wrong number of arguments for 'COMMANDNAME' command.Methods which are marked with
(*)have explicitthrow new ArgumentOutOfRangeException(...)for empty collections, so they differ from the others.However, I think that they can be converted to act as no-op to be consistent with other methods which handle empty arrays gracefully. At least it doesn't make sense to throw
ArgumentOutOfRangeException, because there's no range. It should have been justArgumentException. I understand that it's not always possible not to throw exceptions (or throw exception of another type) because of compatibility reasons. Just thoughts.NickCraver commentedon Jan 31, 2022
I have some large PRs in pipe around normalizing docs and such, so this would wait until after, but I think it's reasonable to put a similar check in here for
.Length == 0 => defaultlike we do in other places. That should be a net win without breaking anyone. Thoughts?mgravell commentedon Aug 25, 2026
Closed by #3192