Skip to content

Commit

Permalink
Merge pull request #886 from tursodatabase/fix_ref
Browse files Browse the repository at this point in the history
Fix error handling of Ref
  • Loading branch information
haaawk authored Jan 11, 2024
2 parents f6577e1 + 3db9965 commit ae9a0e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
12 changes: 7 additions & 5 deletions libsql-server/src/rpc/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ impl ProxyService {
let namespace_jwt_key = self.namespaces.with(namespace, |ns| ns.jwt_key()).await;
let namespace_jwt_key = match namespace_jwt_key {
Ok(Ok(jwt_key)) => Ok(jwt_key),
Err(crate::error::Error::NamespaceDoesntExist(_)) => Ok(None),
Err(e) => Err(tonic::Status::internal(format!(
"Error fetching jwt key for a namespace: {}",
e
))),
Err(e) => match e.as_ref() {
crate::error::Error::NamespaceDoesntExist(_) => Ok(None),
_ => Err(tonic::Status::internal(format!(
"Error fetching jwt key for a namespace: {}",
e
))),
},
Ok(Err(e)) => Err(tonic::Status::internal(format!(
"Error fetching jwt key for a namespace: {}",
e
Expand Down
20 changes: 11 additions & 9 deletions libsql-server/src/rpc/replica_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ impl ReplicaProxyService {
authenticated.upgrade_grpc_request(req);
Ok(())
}
Err(crate::error::Error::NamespaceDoesntExist(_)) => {
let authenticated = self.auth.authenticate_grpc(req, false, None)?;
authenticated.upgrade_grpc_request(req);
Ok(())
}
Err(e) => Err(Status::internal(format!(
"Error fetching jwt key for a namespace: {}",
e
))),
Err(e) => match e.as_ref() {
crate::error::Error::NamespaceDoesntExist(_) => {
let authenticated = self.auth.authenticate_grpc(req, false, None)?;
authenticated.upgrade_grpc_request(req);
Ok(())
}
_ => Err(Status::internal(format!(
"Error fetching jwt key for a namespace: {}",
e
))),
},
Ok(Err(e)) => Err(Status::internal(format!(
"Error fetching jwt key for a namespace: {}",
e
Expand Down

0 comments on commit ae9a0e4

Please sign in to comment.