-
Notifications
You must be signed in to change notification settings - Fork 32
fix(sidecar): JSON-RPC error codes #658
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
Conversation
| impl From<CommitmentError> for JsonError { | ||
| fn from(err: CommitmentError) -> Self { | ||
| // Reference: https://www.jsonrpc.org/specification#error_object | ||
| // TODO: the custom defined ones should be clearly documented. |
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.
We should write custom defined errors in the bolt documentation website
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.
cc @mempirate, if you want to take a look at current error codes
763126a to
6c22d7a
Compare
d603515 to
d94bb81
Compare
| /// FIXME: (thedevbirb, 2025-13-01) this should be removed because it is dead code, | ||
| /// but it allows Rust to pull the correct axum version and not older ones from | ||
| /// dependencies (commit-boost). |
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.
huh... what? this is a new one...
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.
This is what I'm getting if I remove that variant:
error[E0277]: the trait bound `WithRejection<axum::Json<JsonRpcRequest>, CommitmentError>: FromRequest<Arc<CommitmentsApiInner>, _>` is not satisfied because the trait comes from a different crate version
--> src/api/commitments/server/handlers.rs:51:38
|
51 | WithRejection(Json(payload), _): WithRejection<Json<JsonRpcRequest>, CommitmentError>,
| ^^^^^^^^^^^^^ the trait `FromRequest<Arc<CommitmentsApiInner>, _>` is not implemented for `WithRejection<axum::Json<JsonRpcRequest>, CommitmentError>`
|
= note: Function argument is not a valid axum extractor.
See `https://docs.rs/axum/0.8/axum/extract/index.html` for details
note: there are multiple different versions of crate `axum_core` in the dependency graph
--> /Users/birb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.5.0/src/extract/mod.rs:85:1
|
85 | pub trait FromRequest<S, M = private::ViaRequest>: Sized {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src/api/builder.rs:3:5
|
3 | use axum::{
| ---- one version of crate `axum_core` is used here, as a dependency of crate `axum`
|
::: src/signer/commit_boost.rs:8:5
|
8 | use cb_common::{
| --------- one version of crate `axum_core` is used here, as a dependency of crate `axum`
|
::: /Users/birb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-extra-0.10.0/src/extract/with_rejection.rs:60:1
|
60 | pub struct WithRejection<E, R>(pub E, pub PhantomData<R>);
| ------------------------------ this type doesn't implement the required trait
|
::: /Users/birb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-core-0.4.5/src/ext_traits/request.rs:6:5
|
6 | pub trait Sealed {}
| ---------------- this is the found trait
= help: you can use `cargo tree` to explore your dependency tree
error[E0277]: the trait bound `fn(HeaderMap, axum::extract::State<Arc<CommitmentsApiInner>>, WithRejection<axum::Json<JsonRpcRequest>, CommitmentError>) -> impl futures::Future<Output = Result<axum::Json<JsonRpcResponse>, CommitmentError>> {handlers::rpc_entrypoint}: Handler<_, _>` is not satisfied because the trait comes from a different crate version
--> src/api/commitments/server/mod.rs:170:26
|
170 | .route("/", post(handlers::rpc_entrypoint))
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Handler<_, _>` is not implemented for fn item `fn(HeaderMap, State<Arc<CommitmentsApiInner>>, WithRejection<Json<JsonRpcRequest>, ...>) -> ... {rpc_entrypoint}`
|
= note: the full name for the type has been written to '/Users/birb/work/cb/bolt/bolt-sidecar/target/debug/deps/bolt_sidecar-4f96b73b107ca223.long-type-2057463047293510438.txt'
= note: consider using `--verbose` to print the full type name to the console
= note: Consider using `#[axum::debug_handler]` to improve the error message
note: there are multiple different versions of crate `axum` in the dependency graph
--> /Users/birb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.8.1/src/handler/mod.rs:134:1
|
134 | pub trait Handler<T, S>: Clone + Send + Sync + Sized + 'static {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src/api/builder.rs:3:5
|
3 | use axum::{
| ---- one version of crate `axum` is used here, as a direct dependency of the current crate
|
::: src/signer/commit_boost.rs:8:5
|
8 | use cb_common::{
| --------- one version of crate `axum` is used here, as a dependency of crate `cb_common`
|
::: /Users/birb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/axum-0.7.9/src/boxed.rs:62:1
|
62 | pub(crate) trait ErasedIntoRoute<S, E>: Send {
| -------------------------------------------- this is the found trait
= help: you can use `cargo tree` to explore your dependency tree
For more information about this error, try `rustc --explain E0277`.
warning: `bolt-sidecar` (lib) generated 1 warning
error: could not compile `bolt-sidecar` (lib) due to 2 previous errors; 1 warning emitted
I cannot override the axum version of the dependency because it is a breaking change. I think it's fine. Let's wait until they update
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.
Ok fine with me! Will try to bump axum on commit boost
mempirate
left a comment
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.
Nice job
Some internal errors were reported with a wrong status code, and others were not matching the JSON-RPC specification closely.
The changes required a small refactoring here and there.