Skip to content

Conversation

@prk-Jr
Copy link
Collaborator

@prk-Jr prk-Jr commented Jan 22, 2026

Unified error reporting across storage and signing modules allows for better debugging and traceability. Bare error enums previously lacked context on where failures originated. Using meaningful reports with attached context ensures that logs provide actionable information for operations teams without requiring changes to the core error variants.

Resolves: #191

Unified error reporting across storage and signing modules allows for better debugging and traceability. Bare error enums previously lacked context on where failures originated. Using meaningful reports with attached context ensures that logs provide actionable information for operations teams without requiring changes to the core error variants.

Resolves: #191
Copy link
Collaborator

@aram356 aram356 left a comment

Choose a reason for hiding this comment

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

👍 Looks good overall. Some improvement will get us closer to consistency. Thanks

String::from_utf8(bytes).map_err(|e| TrustedServerError::Configuration {
message: format!("Failed to decode secret as UTF-8: {}", e),
String::from_utf8(bytes).change_context(TrustedServerError::Configuration {
message: format!("Failed to decode secret as UTF-8: {}", key),
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔧 We should not include key here.

let active_kids_str =
store
.get("active-kids")
.change_context(TrustedServerError::Configuration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔧 change_context() to errors that already come wrapped in Report<TrustedServerError> from FastlyConfigStore::get(). This creates double-wrapping which may produce verbose error chains:

use attach_printable()

let active_kids_str = store
    .get("active-kids")
    .attach_printable("while fetching active kids list")?;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

attach_printable is deprecated since 0.6.0, using attach instead

let key_bytes =
secret_store
.get(&key_id)
.change_context(TrustedServerError::Configuration {
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔧 change_context() to errors that already come wrapped in Report<TrustedServerError. This creates double-wrapping which may produce verbose error chains:

use attach_printable()

let key_bytes = secret_store
     .get(&key_id)
    .attach_printable(format!("Failed to get signing key for kid: {}", key_id))?;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

attach_printable is deprecated since 0.6.0, using attach instead

message: format!("Failed to ensure API backend: {}", e),
}
})?;
message: "Failed to ensure API backend".to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔧 Should use .attach_printable_lazy(|| e.to_string())

CONTRIBUTING.md Outdated

Consistency is the most important. Following the existing Rust style, formatting, and naming conventions of the file you are modifying and of the overall project. Failure to do so will result in a prolonged review process that has to focus on updating the superficial aspects of your code, rather than improving its functionality and performance.

Style and format will be enforced with a linter when PR is crated.
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ Please fix typo crated -> created


#[test]
fn test_request_signer_sign() {
// We propagate errors in tests too, or unwrap.
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ Change to // Report unwraps print full error chain on test failure

prk-Jr and others added 2 commits January 27, 2026 11:43
Using  on errors that are already of the correct type causes redundant nesting in the error report. This switches to  to add context without changing the error type, producing cleaner error chains.

Resolves: #191
…se-between-reporttrustedservererror-and-bare-trustedservererror
@prk-Jr prk-Jr requested a review from aram356 January 27, 2026 06:38
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.

Standardize error handling patterns: Choose between Report<TrustedServerError> and bare TrustedServerError

3 participants