Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260209.1
260810.0
6 changes: 6 additions & 0 deletions crates/db/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use {
},
};

const MAX_HSCAN_COUNT: u32 = 5000;

struct Inner {
storage: Storage,
}
Expand Down Expand Up @@ -169,6 +171,10 @@ impl StorageApi for Server {
.map(|card| Output::Cardinality(card as u64)),

operation::Owned::HScan(op) => {
if op.count > MAX_HSCAN_COUNT {
return Err(Error::invalid_argument());
}

let opts = ScanOptions::new(op.count as usize).with_cursor(op.cursor);

self.map_storage()
Expand Down
10 changes: 9 additions & 1 deletion crates/storage_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ pub enum ErrorKind {
/// Internal error.
Internal,

/// Invalid argument.
InvalidArgument,

/// Transport error.
Transport,

Expand Down Expand Up @@ -465,6 +468,11 @@ impl Error {
Self::new(ErrorKind::Internal)
}

/// Creates a new [`Error`] with [`ErrorKind::InvalidArgument`].
pub const fn invalid_argument() -> Self {
Self::new(ErrorKind::InvalidArgument)
}

pub fn with_message(mut self, message: impl ToString) -> Self {
self.message = Some(message.to_string());
self
Expand All @@ -478,7 +486,7 @@ impl Error {
/// Indicates whether this [`Error`] is transient and can be retried.
pub fn is_transient(&self) -> bool {
match self.kind {
ErrorKind::Unauthorized | ErrorKind::Unknown => false,
ErrorKind::Unauthorized | ErrorKind::InvalidArgument | ErrorKind::Unknown => false,
ErrorKind::KeyspaceVersionMismatch
| ErrorKind::Timeout
| ErrorKind::Internal
Expand Down
3 changes: 3 additions & 0 deletions crates/storage_api/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ enum ErrorCode {
Internal = 0,
Unauthorized = 1,
KeyspaceVersionMismatch = 2,
InvalidArgument = 3,
}

type Result<T, E = Error> = std::result::Result<T, E>;
Expand All @@ -299,6 +300,7 @@ impl From<Error> for crate::Error {
ErrorCode::Unauthorized => ErrorKind::Unauthorized,
ErrorCode::KeyspaceVersionMismatch => ErrorKind::KeyspaceVersionMismatch,
ErrorCode::Internal => ErrorKind::Internal,
ErrorCode::InvalidArgument => ErrorKind::InvalidArgument,
};

Self {
Expand All @@ -315,6 +317,7 @@ impl From<crate::ErrorKind> for ErrorCode {
match kind {
ErrorKind::Unauthorized => ErrorCode::Unauthorized,
ErrorKind::KeyspaceVersionMismatch => ErrorCode::KeyspaceVersionMismatch,
ErrorKind::InvalidArgument => ErrorCode::InvalidArgument,

ErrorKind::Internal
| ErrorKind::Timeout
Expand Down
Loading