Skip to content

Conversation

gradyzhuo
Copy link
Owner

@gradyzhuo gradyzhuo commented Sep 22, 2025

PR Type

Bug fix


Description

  • Improved error message formatting with backticks around usage parameter

  • Enhanced error descriptions from "error:" to "full error:"

  • Added complete error information in IOError handling


Diagram Walkthrough

flowchart LR
  A["Error Handling Functions"] --> B["Enhanced Error Messages"]
  B --> C["Backticks Around Usage"]
  B --> D["Full Error Details"]
Loading

File Walkthrough

Relevant files
Bug fix
KurrentError.swift
Enhanced error message formatting and descriptions             

Sources/KurrentDB/Core/Error/KurrentError.swift

  • Added backticks around usage parameter in error messages for better
    formatting
  • Changed "error:" to "full error:" for more descriptive error reporting
  • Enhanced IOError handling to include complete error information
+5/-5     

Summary by CodeRabbit

  • Bug Fixes
    • Clarified error messages for async and sync operations: failures now include the operation context in backticks and the full underlying error for better troubleshooting.
    • Unknown I/O errors now report the specific usage context and full origin.
    • No changes to public APIs; only error reporting text was improved.

Copy link
Contributor

coderabbitai bot commented Sep 22, 2025

Walkthrough

Updates internal error messages in KurrentError: unknown errors and IOError.rethrow now include the usage wrapped in backticks and the phrase "full error" with the original error text. No public APIs or signatures were changed.

Changes

Cohort / File(s) Summary of Changes
Error messaging updates
Sources/KurrentDB/Core/Error/KurrentError.swift
Adjusted error string formatting: unknown errors and fallback messages in async/sync withRethrowingError paths now use backticked usage and "full error: ..." wording; IOError.rethrow default now returns "<usage> failed, full error: ." No exported signatures changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through logs with whiskers alert,
Backticked usage makes the errors less curt.
"Full error" now speaks what once hid from sight,
I nibble at bugs and hop into the night.
A rabbit's small cheer for clearer debug light 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change—updating error message wording to include the full error description and formatting tweaks. The "[UPDATE]" prefix is superfluous but does not make the title unclear; it is concise, relevant, and tied to the changeset.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/error-message

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8a5a98 and 3f04c16.

📒 Files selected for processing (1)
  • Sources/KurrentDB/Core/Error/KurrentError.swift (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Sources/KurrentDB/Core/Error/KurrentError.swift
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Swift 6.0 on ubuntu-latest
  • GitHub Check: Swift 6.1 on ubuntu-latest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 Security concerns

Sensitive information exposure:
Propagating full underlying errors (\(error), \(origin)) into .internalClientError can leak internal details (endpoints, file paths, system errno context). If these messages reach clients or logs without redaction, consider downgrading to concise messages and attaching the raw error as a cause/metadata only for server-side logs.

⚡ Recommended focus areas for review

Potential Redundancy

The final unconditional throws after the catch blocks appears unreachable in both async and sync variants, since all paths either return or throw. Confirm compiler doesn't warn and consider removing for clarity.

    throw .internalClientError(reason: "`\(usage)` failed.")
}
Consistency

Mixed phrasing "full error:" vs "full error:" and trailing period in IOError path; ensure error message format is consistent across all branches and with existing logging/telemetry expectations.

        throw .internalClientError(reason: "`\(usage)` failed. full error: \(error)")
    }
    throw .internalClientError(reason: "`\(usage)` failed.")
}

func withRethrowingError<T>(usage: String, action: @Sendable () throws -> T) throws(KurrentError) -> T {
    do {
        return try action()
    } catch let error as KurrentError {
        throw error
    } catch let error as RPCError {
        try error.rethrow(usage: usage, origin: error)
    } catch {
        throw .internalClientError(reason: "`\(usage)` failed. full error: \(error)")
    }
    throw .internalClientError(reason: "`\(usage)` failed.")
}
Sensitive Data in Errors

Including raw error descriptions (e.g., origin) in client-facing messages may expose internal details. Verify these surfaces are not user-facing or sanitize before propagation.

extension IOError {
    func rethrow(usage: String, origin: RPCError) throws(KurrentError) {
        switch errnoCode {
        case 61:
            throw .grpcConnectionError(cause: origin)
        default:
            throw .internalClientError(reason: "`\(usage)` failed, full error: \(origin).")
        }
    }

Copy link

qodo-merge-pro bot commented Sep 22, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Remove unreachable error throwing code

Remove the unreachable throw statement that follows the do-catch block, as all
paths within the block already either return a value or throw an error.

Sources/KurrentDB/Core/Error/KurrentError.swift [156-159]

 } catch {
     throw .internalClientError(reason: "`\(usage)` failed. full error: \(error)")
 }
-throw .internalClientError(reason: "`\(usage)` failed.")
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that the throw statement on line 159 is unreachable because all preceding code paths in the do-catch block either return or throw, making it dead code. Removing it improves code quality.

Medium
  • Update

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Sources/KurrentDB/Core/Error/KurrentError.swift (1)

94-98: Don't use description for equality — match enum cases/semantic associated values

Comparing lhs.description == rhs.description ties equality to presentation text; changing message strings will break callers/tests (e.g. Tests/StreamsTests/StreamsTests.swift:29 expects KurrentError.resourceNotFound(reason: "...")).

  • Replace the Equatable implementation in Sources/KurrentDB/Core/Error/KurrentError.swift (≈ lines 94–98) with explicit case matching that compares the enum case and only the semantic associated values (IDs, keys). Omit or normalize presentation-only "reason" strings unless they are part of the semantic identity.
  • Update tests that assert full descriptions (e.g. Tests/StreamsTests/StreamsTests.swift:29) to assert the error case and/or specific associated values instead of exact message text.

Suggested approach (sketch):
switch (lhs, rhs) {
case (.resourceNotFound(let a), .resourceNotFound(let b)): return a == b
case (.notLeaderException, .notLeaderException): return true
/* compare other cases' semantic fields */
default: return false
}

🧹 Nitpick comments (4)
Sources/KurrentDB/Core/Error/KurrentError.swift (4)

157-160: Add period and double‑check leakage of sensitive details in “full error”.

  • Consistency nit: end the interpolated error with a period to match other messages.
  • Please verify that bubbling up \(error) won’t surface secrets, tokens, or endpoints in user‑visible contexts.

Apply this diff:

-        throw .internalClientError(reason: "`\(usage)` failed. full error: \(error)")
+        throw .internalClientError(reason: "`\(usage)` failed. full error: \(error).")

If you want a safer default, consider redacting known patterns (bearer tokens, connection URIs) before interpolation; I can draft a small sanitizer if you’d like.


191-199: Unify punctuation style for “full error” and maintain consistency.

Use a period before “full error” (to match lines 157/170) for consistency.

-            throw .internalClientError(reason: "`\(usage)` failed, full error: \(origin).")
+            throw .internalClientError(reason: "`\(usage)` failed. full error: \(origin).")

175-179: Match the new backtick style in the generic Error.rethrow helper.

Align message formatting with other sites that now backtick usage.

-        throw .internalClientError(reason: "\(usage) failed.")
+        throw .internalClientError(reason: "`\(usage)` failed.")

74-76: Minor grammar: “fill an issue” → “file an issue”.

Small polish in user-facing text.

-            "Unexpected internal client error. Please fill an issue on GitHub. reason: \(reason)"
+            "Unexpected internal client error. Please file an issue on GitHub. reason: \(reason)"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec6900d and c8a5a98.

📒 Files selected for processing (1)
  • Sources/KurrentDB/Core/Error/KurrentError.swift (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Swift 6.0 on ubuntu-latest
  • GitHub Check: Swift 6.1 on ubuntu-latest
🔇 Additional comments (1)
Sources/KurrentDB/Core/Error/KurrentError.swift (1)

170-173: Mirror the punctuation fix and leakage check in the sync path.

Same comments as the async variant: add a trailing period and verify no sensitive data is exposed.

-        throw .internalClientError(reason: "`\(usage)` failed. full error: \(error)")
+        throw .internalClientError(reason: "`\(usage)` failed. full error: \(error).")

@codecov-commenter
Copy link

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

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 24.83%. Comparing base (ec6900d) to head (3f04c16).

Files with missing lines Patch % Lines
Sources/KurrentDB/Core/Error/KurrentError.swift 0.00% 5 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #61   +/-   ##
=======================================
  Coverage   24.83%   24.83%           
=======================================
  Files         153      153           
  Lines       19653    19653           
=======================================
  Hits         4880     4880           
  Misses      14773    14773           

☔ 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.

@gradyzhuo gradyzhuo merged commit 0eee269 into main Sep 22, 2025
3 checks passed
@gradyzhuo gradyzhuo deleted the fix/error-message branch September 22, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants