fix: replace fatalError with thrown error in signWithOperator#595
Open
fix: replace fatalError with thrown error in signWithOperator#595
Conversation
Signed-off-by: Rob Walworth <robert.walworth@swirldslabs.com>
5 tasks
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a crash in
signWithOperator(_:)that occurred when the client had no operator configured. Instead of callingfatalError, which unconditionally terminates the process, the method now throwsHError.noPayerAccountOrTransactionId, giving callers the opportunity to handle the error gracefully.Key Changes:
fatalError("todo: error here (Client had no operator)")withthrow HError.noPayerAccountOrTransactionIdinTransaction.signWithOperator(_:)Changes
Replace
fatalErrorwith a Thrown ErrorProblem:
Transaction.signWithOperator(_:)calledfatalErrorwhen the client had no operator, crashing the entire process instead of surfacing a recoverable error.Discovery: This bug was surfaced by the Swift SDK TCK compatibility workflow (hiero-sdk-tck#636). The
HieroTCKserver runs inside a Vapor process — when a test triggeredsignWithOperatoron a client with no operator set, thefatalErrorkilled the entire server process mid-run, causing all 317 subsequent TCK tests to fail withECONNREFUSEDon port 8544.Root Cause: A
// TODOstub was left in place that usedfatalErroras a placeholder.Fix: The method already throws (its signature is
throws), andHError.noPayerAccountOrTransactionIdis the established error for this exact condition — already used in three other locations in the codebase (Transaction.swift:786, Transaction.swift:901, ChunkedTransaction.swift:217). Replacing thefatalErrorwith this throw makes the behavior consistent and recoverable.Files Changed:
Testing
Test Plan:
signWithOperatoron a client without an operator now throws instead of crashingFiles Changed Summary
Sources/Hiero/Transaction.swiftBreaking Changes
None. The method signature was already declared
throws. Callers that previously crashed (due tofatalError) will now receive a thrownHError.noPayerAccountOrTransactionIderror, which is strictly an improvement.