-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tx_cache): surface auth token retrieval errors #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,11 +1,40 @@ | ||||||
| use crate::perms::oauth::SharedToken; | ||||||
| use serde::de::DeserializeOwned; | ||||||
| use signet_tx_cache::{ | ||||||
| error::Result, | ||||||
| error::TxCacheError, | ||||||
| types::{BundleKey, CacheObject, TxCacheBundle, TxCacheBundleResponse, TxCacheBundlesResponse}, | ||||||
| TxCache, | ||||||
| }; | ||||||
| use tracing::{instrument, warn}; | ||||||
| use thiserror::Error; | ||||||
| use tokio::sync::watch; | ||||||
| use tracing::instrument; | ||||||
|
|
||||||
| /// Result type for [`BuilderTxCache`] operations. | ||||||
| pub type Result<T> = std::result::Result<T, BuilderTxCacheError>; | ||||||
|
|
||||||
| /// Errors that can occur when using the [`BuilderTxCache`] client. | ||||||
| #[derive(Debug, Error)] | ||||||
| pub enum BuilderTxCacheError { | ||||||
| /// Failed to retrieve the authentication token. | ||||||
| #[error("failed to retrieve auth token: {0}")] | ||||||
| TokenRetrieval(#[from] watch::error::RecvError), | ||||||
|
|
||||||
| /// An error occurred during a TxCache operation. | ||||||
| #[error(transparent)] | ||||||
| TxCache(#[from] TxCacheError), | ||||||
| } | ||||||
|
|
||||||
| impl From<reqwest::Error> for BuilderTxCacheError { | ||||||
| fn from(err: reqwest::Error) -> Self { | ||||||
| BuilderTxCacheError::TxCache(TxCacheError::Reqwest(err)) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By not using
Suggested change
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| impl From<url::ParseError> for BuilderTxCacheError { | ||||||
| fn from(err: url::ParseError) -> Self { | ||||||
| BuilderTxCacheError::TxCache(TxCacheError::Url(err)) | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| const BUNDLES: &str = "bundles"; | ||||||
|
|
||||||
|
|
@@ -77,10 +106,7 @@ impl BuilderTxCache { | |||||
| T: DeserializeOwned + CacheObject, | ||||||
| { | ||||||
| let url = self.tx_cache.url().join(join)?; | ||||||
| let secret = self.token.secret().await.unwrap_or_else(|_| { | ||||||
| warn!("Failed to get token secret"); | ||||||
| "".to_string() | ||||||
| }); | ||||||
| let secret = self.token.secret().await?; | ||||||
|
|
||||||
| self.tx_cache | ||||||
| .client() | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| #![cfg(feature = "perms")] | ||
|
|
||
| use init4_bin_base::perms::{tx_cache::BuilderTxCache, SharedToken}; | ||
| use init4_bin_base::perms::{ | ||
| tx_cache::{BuilderTxCache, BuilderTxCacheError}, | ||
| SharedToken, | ||
| }; | ||
| use signet_tx_cache::TxCacheError; | ||
|
|
||
| const URL: &str = "https://transactions.parmigiana.signet.sh"; | ||
|
|
@@ -12,5 +15,8 @@ async fn test_tx_cache_get_bundles() { | |
|
|
||
| let bundles = client.get_bundles(None).await.unwrap_err(); | ||
|
|
||
| assert!(matches!(bundles, TxCacheError::NotOurSlot)); | ||
| assert!(matches!( | ||
| bundles, | ||
| BuilderTxCacheError::TxCache(TxCacheError::NotOurSlot) | ||
| )); | ||
|
Comment on lines
+18
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this matches the new behaviour, but the test is ignored, so not picked up in CI. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.