Skip to content

fix: view error on failed transaction#154

Merged
MicBun merged 3 commits intomainfrom
viewError
Jul 31, 2025
Merged

fix: view error on failed transaction#154
MicBun merged 3 commits intomainfrom
viewError

Conversation

@MicBun
Copy link
Copy Markdown
Member

@MicBun MicBun commented Jul 31, 2025

Description

Related Problem

resolves: #153

How Has This Been Tested?

tested locally

Summary by CodeRabbit

  • New Features

    • Added a new example demonstrating how to deploy a composed stream with taxonomy in a single operation, including full lifecycle management and cleanup.
    • Introduced documentation and example code for streamlined composed stream deployment and taxonomy setup.
  • Bug Fixes

    • Enhanced error handling for transaction confirmations, now distinguishing between transport errors and transaction execution failures, and providing more detailed logging and feedback.
  • Documentation

    • Updated API reference and lifecycle documentation to clarify transaction result code checking and improve example robustness.
    • Added comprehensive README for the new composed stream with taxonomy example, including usage instructions, expected output, and best practices.

@MicBun MicBun requested a review from outerlook July 31, 2025 09:33
@MicBun MicBun self-assigned this Jul 31, 2025
@MicBun MicBun added documentation Improvements or additions to documentation fix labels Jul 31, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

The changes introduce enhanced error handling for transaction confirmation across code, documentation, and examples. After waiting for a transaction, the code now checks the transaction result code to detect execution failures, not just transport errors. Documentation and examples are updated to reflect this improved pattern, and a new composed stream taxonomy example is added.

Changes

Cohort / File(s) Change Summary
Enhanced Transaction Error Handling (Code)
core/tnclient/deploy_composed_streams_with_taxonomy.go, examples/complex_stream_example/main.go
Added checks for transaction result codes after waiting for transactions, logging or returning errors if the code indicates failure, distinguishing between transport and execution errors.
Enhanced Transaction Error Handling (Examples & Cleanup)
examples/complex_stream_example/README.md
Updated error handling in stream destruction example to check transaction result codes and log failures with details.
Enhanced Transaction Error Handling (Documentation)
docs/api-reference.md, docs/stream-lifecycle.md
Updated documentation and example code snippets to demonstrate explicit checking of transaction result codes after waiting for transactions.
New Composed Stream Taxonomy Example
examples/compose_and_set_taxonomy_example/README.md, examples/compose_and_set_taxonomy_example/main.go, examples/compose_and_set_taxonomy_example/go.mod
Added a new example with documentation and module definition, demonstrating deploying a composed stream with taxonomy, verifying taxonomy, fetching composed data, and cleaning up.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Client
    participant Network

    User->>Client: Initiate transaction (e.g., deploy stream)
    Client->>Network: Submit transaction
    Network-->>Client: Transaction confirmation (tx result)
    Client->>Client: Check for error from WaitForTx
    alt Error present
        Client-->>User: Report transport error
    else No error
        Client->>Client: Check tx result code
        alt Result code is success
            Client-->>User: Proceed (success)
        else Result code is failure
            Client-->>User: Report execution failure with log
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Assessment against linked issues

Objective Addressed Explanation
Show error details on failed transaction, not just transport errors (#153)
Distinguish between transaction execution failure and transport error (#153)
Update documentation/examples to demonstrate proper transaction error handling (#153)

Suggested reviewers

  • outerlook

Poem

A rabbit hopped through code so neat,
With checks for errors—none discreet!
Now failed transactions show their face,
No more confusion, just clear trace.
Composed streams join the bunny’s lore,
Robustness shines from shore to shore!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 4281e17 and d1ce449.

📒 Files selected for processing (1)
  • examples/compose_and_set_taxonomy_example/go.mod (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • examples/compose_and_set_taxonomy_example/go.mod
⏰ 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). (1)
  • GitHub Check: test
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch viewError

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@holdex
Copy link
Copy Markdown

holdex bot commented Jul 31, 2025

Bug Report Checklist

Status Commit Link Bug Author
❌ Not Submitted

@MicBun, please use git blame and specify the link to the commit link that has introduced this bug.

Send the following message in this PR: `@pr-time-tracker bug commit [link](url) && bug author @name`

@holdex
Copy link
Copy Markdown

holdex bot commented Jul 31, 2025

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h 30min Update time Jul 31, 2025, 9:44 AM

@MicBun
Copy link
Copy Markdown
Member Author

MicBun commented Jul 31, 2025

@pr-time-tracker bug commit not from previous commit

Copy link
Copy Markdown
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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f646ed5 and 4281e17.

⛔ Files ignored due to path filters (1)
  • examples/compose_and_set_taxonomy_example/go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • README.md (2 hunks)
  • core/tnclient/deploy_composed_streams_with_taxonomy.go (3 hunks)
  • docs/api-reference.md (2 hunks)
  • docs/stream-lifecycle.md (1 hunks)
  • examples/complex_stream_example/README.md (1 hunks)
  • examples/complex_stream_example/main.go (6 hunks)
  • examples/compose_and_set_taxonomy_example/README.md (1 hunks)
  • examples/compose_and_set_taxonomy_example/go.mod (1 hunks)
  • examples/compose_and_set_taxonomy_example/main.go (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: MicBun
PR: trufnetwork/sdk-go#138
File: examples/cache_example.go:21-21
Timestamp: 2025-07-10T15:39:48.576Z
Learning: For example code in the trufnetwork/sdk-go repository, the maintainer MicBun prefers to keep examples simple and focused on demonstrating functionality rather than implementing production-ready security practices like environment variables for sensitive values.
core/tnclient/deploy_composed_streams_with_taxonomy.go (1)

Learnt from: MicBun
PR: #138
File: examples/cache_example.go:21-21
Timestamp: 2025-07-10T15:39:48.576Z
Learning: For example code in the trufnetwork/sdk-go repository, the maintainer MicBun prefers to keep examples simple and focused on demonstrating functionality rather than implementing production-ready security practices like environment variables for sensitive values.

examples/complex_stream_example/main.go (1)

Learnt from: MicBun
PR: #138
File: examples/cache_example.go:21-21
Timestamp: 2025-07-10T15:39:48.576Z
Learning: For example code in the trufnetwork/sdk-go repository, the maintainer MicBun prefers to keep examples simple and focused on demonstrating functionality rather than implementing production-ready security practices like environment variables for sensitive values.

examples/compose_and_set_taxonomy_example/go.mod (1)

Learnt from: MicBun
PR: #138
File: examples/cache_example.go:21-21
Timestamp: 2025-07-10T15:39:48.576Z
Learning: For example code in the trufnetwork/sdk-go repository, the maintainer MicBun prefers to keep examples simple and focused on demonstrating functionality rather than implementing production-ready security practices like environment variables for sensitive values.

examples/compose_and_set_taxonomy_example/README.md (1)

Learnt from: MicBun
PR: #138
File: examples/cache_example.go:21-21
Timestamp: 2025-07-10T15:39:48.576Z
Learning: For example code in the trufnetwork/sdk-go repository, the maintainer MicBun prefers to keep examples simple and focused on demonstrating functionality rather than implementing production-ready security practices like environment variables for sensitive values.

examples/compose_and_set_taxonomy_example/main.go (1)

Learnt from: MicBun
PR: #138
File: examples/cache_example.go:21-21
Timestamp: 2025-07-10T15:39:48.576Z
Learning: For example code in the trufnetwork/sdk-go repository, the maintainer MicBun prefers to keep examples simple and focused on demonstrating functionality rather than implementing production-ready security practices like environment variables for sensitive values.

🧬 Code Graph Analysis (1)
examples/compose_and_set_taxonomy_example/main.go (7)
core/tnclient/client.go (2)
  • NewClient (33-54)
  • WithSigner (61-66)
core/util/stream_id.go (3)
  • GenerateStreamId (12-27)
  • StreamId (29-31)
  • NewRawStreamId (45-47)
core/types/composed_stream.go (3)
  • Taxonomy (11-17)
  • TaxonomyItem (19-22)
  • DescribeTaxonomiesParams (24-28)
core/types/stream_types.go (1)
  • StreamLocator (6-11)
core/util/ethereum_address.go (1)
  • Unsafe_NewEthereumAddressFromString (45-51)
core/contractsapi/composed_stream.go (1)
  • LoadComposedActions (29-36)
core/types/stream.go (1)
  • GetRecordInput (12-21)
🪛 markdownlint-cli2 (0.17.2)
docs/api-reference.md

128-128: Hard tabs
Column: 1

(MD010, no-hard-tabs)


129-129: Hard tabs
Column: 1

(MD010, no-hard-tabs)


130-130: Hard tabs
Column: 1

(MD010, no-hard-tabs)


133-133: Hard tabs
Column: 1

(MD010, no-hard-tabs)


135-135: Hard tabs
Column: 1

(MD010, no-hard-tabs)


221-221: Hard tabs
Column: 1

(MD010, no-hard-tabs)


222-222: Hard tabs
Column: 1

(MD010, no-hard-tabs)


223-223: Hard tabs
Column: 1

(MD010, no-hard-tabs)


224-224: Hard tabs
Column: 1

(MD010, no-hard-tabs)


225-225: Hard tabs
Column: 1

(MD010, no-hard-tabs)

⏰ 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). (1)
  • GitHub Check: test
🔇 Additional comments (21)
examples/complex_stream_example/README.md (1)

52-57: LGTM! Enhanced error handling documentation is excellent.

The documentation correctly demonstrates the improved transaction failure handling pattern by checking both the WaitForTx error and the transaction result code. This provides users with clear visibility into transaction failures, directly addressing the PR objective.

docs/stream-lifecycle.md (1)

30-32: LGTM! Proper transaction failure handling documentation.

The addition of explicit transaction result code checking in the documentation is excellent. This shows developers the correct pattern for distinguishing between transport errors and transaction execution failures, improving error visibility as intended by this PR.

core/tnclient/deploy_composed_streams_with_taxonomy.go (3)

6-6: LGTM! Proper import for enhanced error handling.

Adding the kwiltypes import enables access to the CodeOk constant needed for transaction result code validation.


22-27: LGTM! Enhanced error handling for stream deployment.

The addition of transaction result code checking properly distinguishes between transport errors and transaction execution failures. The error message with transaction log provides clear visibility into deployment failures, directly addressing the PR objective.


43-48: LGTM! Consistent error handling for taxonomy setting.

The enhanced error handling pattern is consistently applied to the taxonomy setting transaction, ensuring that both deployment and configuration failures are properly visible to users.

README.md (2)

398-403: LGTM! Clear example of enhanced transaction error handling.

The README properly demonstrates the improved error handling pattern for stream destruction, showing users how to check both transport errors and transaction execution failures. This directly supports the PR objective of making transaction errors visible.


442-447: LGTM! Consistent error handling in batch operations.

The deferred cleanup function demonstrates proper error handling for multiple stream destruction operations. The consistent pattern of checking transaction result codes and logging failure details provides excellent guidance for developers.

examples/complex_stream_example/main.go (6)

6-6: LGTM: Proper import added for enhanced error handling.

The kwiltypes import is correctly added to support the new transaction result code checking pattern.


61-68: Excellent: Enhanced transaction error handling implemented.

The code now properly distinguishes between transport errors and transaction execution failures. This addresses the core issue where failed transactions weren't visible to users. The pattern correctly checks both the error from WaitForTx and the transaction result code.


78-85: LGTM: Consistent error handling pattern for stream deployment.

The same robust error handling pattern is applied here, ensuring both network errors and transaction execution failures are properly caught and reported.


99-104: LGTM: Proper error handling for composed stream deployment.

Consistent implementation of the enhanced error checking pattern that addresses the visibility issue described in the PR objectives.


119-126: LGTM: Enhanced error handling for record insertion.

The error handling correctly captures both transport failures and transaction execution failures, providing complete visibility into transaction outcomes.


194-199: LGTM: Consistent error handling for taxonomy operations.

The pattern is applied consistently across all transaction types, ensuring comprehensive error visibility throughout the application.

docs/api-reference.md (2)

124-137: Excellent documentation enhancement for transaction error handling.

The documentation now clearly emphasizes the critical importance of checking Result.Code to detect transaction execution failures, not just transport errors. This directly addresses the issue described in the PR where transaction failures weren't visible to users.


221-226: LGTM: Example code updated with enhanced error handling.

The example function correctly demonstrates the new pattern of checking both the error return and the transaction result code, providing a clear template for developers.

examples/compose_and_set_taxonomy_example/README.md (1)

1-123: Excellent comprehensive documentation for the new example.

This README provides clear, well-structured documentation that covers all aspects of the compose and set taxonomy example. It properly documents the enhanced error handling approach, resource lifecycle management, and provides practical guidance for users. The documentation aligns well with the PR's objective of improving transaction error visibility.

examples/compose_and_set_taxonomy_example/main.go (5)

21-21: LGTM: Hardcoded private key appropriate for example code.

Based on previous feedback, simple examples in this repository appropriately use hardcoded values to focus on demonstrating functionality rather than production security practices.


50-57: Excellent: Enhanced error handling in cleanup function.

The deferred cleanup function properly implements the enhanced error handling pattern, checking both transport errors and transaction result codes. This ensures that even cleanup operations provide proper error visibility.


62-87: LGTM: Well-structured taxonomy definition.

The taxonomy is properly structured with realistic stream IDs and addresses. The weights sum correctly to 1.0 (0.33 + 0.33 + 0.34), which is good practice for composed stream taxonomies.


89-96: LGTM: Proper usage of DeployComposedStreamWithTaxonomy.

The method is used correctly and the error handling follows the enhanced pattern introduced in this PR. This demonstrates the streamlined approach for composed stream deployment with taxonomy.


144-158: Good: Graceful handling of expected data retrieval failures.

The code appropriately handles the case where child streams might not have data, treating it as expected behavior rather than a fatal error. This demonstrates good UX practices for composed streams.

MicBun and others added 2 commits July 31, 2025 16:38
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@MicBun
Copy link
Copy Markdown
Member Author

MicBun commented Jul 31, 2025

Merged immediatelye so other dev can use

@MicBun MicBun merged commit fe4ee13 into main Jul 31, 2025
6 checks passed
@MicBun MicBun deleted the viewError branch July 31, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Unable to view error on failed transaction

1 participant