Skip to content
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

editoast: refactor core error #11041

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Conversation

hamz2a
Copy link
Contributor

@hamz2a hamz2a commented Mar 6, 2025

closes #10868

@hamz2a hamz2a requested review from a team as code owners March 6, 2025 09:40
@github-actions github-actions bot added area:front Work on Standard OSRD Interface modules area:editoast Work on Editoast Service labels Mar 6, 2025
@hamz2a hamz2a force-pushed the hai/editoast-refactor-core-error branch from 69b2431 to 83d7f73 Compare March 6, 2025 09:52
@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 35.89744% with 25 lines in your changes missing coverage. Please review.

Project coverage is 80.62%. Comparing base (164c697) to head (1263fcd).
Report is 13 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/views/core_error_response.rs 11.11% 8 Missing ⚠️
editoast/src/views/train_schedule.rs 0.00% 6 Missing ⚠️
editoast/src/core/mod.rs 58.33% 5 Missing ⚠️
editoast/src/views/path/pathfinding.rs 0.00% 3 Missing ⚠️
editoast/src/views/timetable/stdcm.rs 66.66% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #11041      +/-   ##
==========================================
- Coverage   80.63%   80.62%   -0.02%     
==========================================
  Files        1099     1102       +3     
  Lines      112187   112362     +175     
  Branches      745      747       +2     
==========================================
+ Hits        90460    90589     +129     
- Misses      21684    21730      +46     
  Partials       43       43              
Flag Coverage Δ
editoast 72.16% <35.89%> (-0.03%) ⬇️
front 89.92% <ø> (-0.03%) ⬇️
gateway 2.18% <ø> (ø)
osrdyne 2.53% <ø> (ø)
railjson_generator 87.58% <ø> (ø)
tests 87.90% <ø> (ø)

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.

@hamz2a hamz2a force-pushed the hai/editoast-refactor-core-error branch 2 times, most recently from a869efc to 17959f4 Compare March 6, 2025 10:38
Copy link
Contributor

@woshilapin woshilapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Some comment, but mostly unrelated to the work of this PR, could be addressed in another PR.

MqClientError(#[from] MqClientError),

#[error(transparent)]
StandardCoreError(#[from] StandardCoreError),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Standard" feels vague, especially since there is also a variant "Generic". Not sure what each does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm wrong I think we could remove the other GenericCoreError and only keep the StandardCoreError one (maybe simply Core would suffice as a name?)

Copy link
Contributor Author

@hamz2a hamz2a Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GenericCoreError, we serialize the error without a specific format raw_error (example), while for StandardCoreError, we use it to parse the error and get a specific format (example).
Both are used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the difference but since they have the same meaning I believe we could replace GenericCoreError (it was created at a time when Core errors weren't homogeneous if I recall correctly)

@hamz2a hamz2a force-pushed the hai/editoast-refactor-core-error branch from 17959f4 to d32fff5 Compare March 6, 2025 14:04
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for resuming the work on the split in crates!

MqClientError(#[from] MqClientError),

#[error(transparent)]
StandardCoreError(#[from] StandardCoreError),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm wrong I think we could remove the other GenericCoreError and only keep the StandardCoreError one (maybe simply Core would suffice as a name?)

@hamz2a hamz2a force-pushed the hai/editoast-refactor-core-error branch 2 times, most recently from ab5c613 to 2dfb381 Compare March 6, 2025 15:21
@hamz2a hamz2a force-pushed the hai/editoast-refactor-core-error branch from 2dfb381 to 1263fcd Compare March 7, 2025 10:55
@hamz2a hamz2a requested review from leovalais and woshilapin March 7, 2025 14:18
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the changes!

Comment on lines +441 to +445
if let Error::StandardCoreError(standard_core_error) = result {
assert_eq!(standard_core_error, expected_error);
} else {
panic!("Unexpected error type: {:?}", result);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: using assert_eq with the Error variant would be more idiomatic than if-else panicking imo

@@ -290,6 +292,65 @@ impl EditoastError for editoast_models::model::Error {
}
}

impl EditoastError for core::Error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inventory::submit! is missing for translation keys, a few examples in this file or in macro expansion of EeitoastError

Comment on lines +342 to +347
core::Error::UnparsableErrorOutput => Default::default(),
core::Error::ConnectionClosedBeforeMessageCompleted => Default::default(),
core::Error::ConnectionResetByPeer => Default::default(),
core::Error::BrokenPipe => Default::default(),
core::Error::MqClientError(_) => Default::default(),
core::Error::StandardCoreError(_) => Default::default(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
core::Error::UnparsableErrorOutput => Default::default(),
core::Error::ConnectionClosedBeforeMessageCompleted => Default::default(),
core::Error::ConnectionResetByPeer => Default::default(),
core::Error::BrokenPipe => Default::default(),
core::Error::MqClientError(_) => Default::default(),
core::Error::StandardCoreError(_) => Default::default(),
_ => Default::default(),

Comment on lines +19 to +27
pub struct CoreErrorResponse {
#[serde(with = "StatusCodeRemoteDef", default = "default_status_code")]
#[schema(value_type = u16, minimum = 100, maximum = 599)]
pub status: StatusCode,
#[serde(rename = "type")]
pub error_type: String,
pub context: HashMap<String, Value>,
pub message: String,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub(in crate::views) when necessary

@@ -1,4 +1,5 @@
mod authz;
pub mod core_error_response;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub mod core_error_response;
mod core_error_response;
use core_error_response::CoreErrorResponse;

avoids repetition in import paths

pub message: String,
}

impl From<Error> for CoreErrorResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
impl From<Error> for CoreErrorResponse {
impl From<core::Error> for CoreErrorResponse {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:editoast Work on Editoast Service area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

editoast: refactor CoreError
4 participants