Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@PolyProgrammist
Copy link
Contributor

@PolyProgrammist PolyProgrammist commented Sep 29, 2025

According to this code:

#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(deny_unknown_fields)]
pub struct RpcError {
    #[serde(flatten)]
    pub error_struct: Option<RpcErrorKind>,
    /// Deprecated please use the `error_struct` instead
    pub code: i64,
    /// Deprecated please use the `error_struct` instead
    pub message: String,
    /// Deprecated please use the `error_struct` instead
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data: Option<Box<Value>>,
}

#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "name", content = "cause", rename_all = "SCREAMING_SNAKE_CASE")]
pub enum RpcErrorKind {
    RequestValidationError(RpcRequestValidationErrorKind),
    HandlerError(Box<Value>),
    InternalError(Box<Value>),
}

#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, PartialEq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(tag = "name", content = "info", rename_all = "SCREAMING_SNAKE_CASE")]
pub enum RpcRequestValidationErrorKind {
    MethodNotFound { method_name: String },
    ParseError { error_message: String },
}

There is serde_json::Value in both HandlerError and InternalError which leads to the specification saying nothing about the underlying types.

This PR adds new types to the openapi specification so that it contains information on what is the error type for the response. It doesn't modify the RpcErrorKind itself. It only generates different schema

@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 0% with 50 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.64%. Comparing base (da137d5) to head (849402c).

Files with missing lines Patch % Lines
chain/jsonrpc/openapi/src/main.rs 0.00% 50 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #14354      +/-   ##
==========================================
- Coverage   69.65%   69.64%   -0.01%     
==========================================
  Files         875      875              
  Lines      190880   190896      +16     
  Branches   190880   190896      +16     
==========================================
+ Hits       132950   132952       +2     
- Misses      52168    52182      +14     
  Partials     5762     5762              
Flag Coverage Δ
pytests 0.43% <ø> (ø)
pytests-nightly 1.43% <ø> (ø)
unittests 67.88% <0.00%> (-0.01%) ⬇️
unittests-nightly 67.78% <0.00%> (-0.01%) ⬇️
unittests-spice 16.13% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant