Skip to content

chore: update sdk-go depedencies for viewing unsettled market#103

Merged
MicBun merged 2 commits intomainfrom
unsettledPy
Feb 24, 2026
Merged

chore: update sdk-go depedencies for viewing unsettled market#103
MicBun merged 2 commits intomainfrom
unsettledPy

Conversation

@MicBun
Copy link
Member

@MicBun MicBun commented Feb 24, 2026

resolves: #101

Summary by CodeRabbit

  • New Features

    • Example updated to fetch and process markets per state (ACTIVE and SETTLED) with per-state outputs and improved per-market reporting.
    • Enhanced structured display of decoded market details and clearer per-state/per-market error messages.
  • Chores

    • Updated SDK-Go dependency.
    • Public client API updated to support per-state market listing (may require minor code adjustments).

@MicBun MicBun self-assigned this Feb 24, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57e15ef and d511598.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod

📝 Walkthrough

Walkthrough

Refactors the market example to fetch and decode markets per state (ACTIVE, SETTLED) with per-market error handling; updates TNClient.list_markets signature to accept a settled_filter flag; bumps github.com/trufnetwork/sdk-go dependency version in go.mod.

Changes

Cohort / File(s) Summary
Example Refactoring
examples/decode_market_example/main.py
Replaced bulk market fetch with a per-state loop (ACTIVE, SETTLED), added per-state empty handling, per-market full-info fetch, decoding via TNClient.decode_market_data, and nested per-market error reporting.
Client API
trufnetwork_sdk_py/client.py
Public method signature changed to list_markets(self, limit: int, settled_filter: bool), altering callers to pass the settled_filter flag.
Dependency Update
go.mod
Updated github.com/trufnetwork/sdk-go version to v0.6.4-0.20260224122406-a741343e2f37 (dependency signature bump).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • pr-time-tracker

Poem

🐰 I hopped through ACTIVE, then SETTLED, too,
Decoding each market, one by one through,
A tweak to the client, a bump to the core,
Now hashes align and I dig for more! 🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title mentions updating sdk-go dependencies for viewing unsettled markets, but the raw summary shows changes were made to Python example code (examples/decode_market_example/main.py) and a Go module file (go.mod). Clarify whether the primary change is the Go dependency update or the Python example code enhancement. The title appears to focus on the dependency update, but most code changes are in Python example logic.
Linked Issues check ❓ Inconclusive The linked issue #101 requires fixing the Go FFI layer to handle base64-encoded hashes from the backend, but the PR changes only show a Go module version bump and Python example code updates without evidence that the core issue is resolved. Verify that the sdk-go version bump (v0.6.4-0.20260220161451-2f87974cef9c to v0.6.4-0.20260224100843-2b7b7e735e86) actually includes the fix for base64 hash decoding. Confirm that client.list_markets(settled_filter=False) now works with the new dependency.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes relate to supporting unsettled market viewing: Python example updates the logic to handle per-state market fetching with proper filters, and Go module updates the sdk-go dependency version.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unsettledPy

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.

@holdex
Copy link

holdex bot commented Feb 24, 2026

Time Submission Status

Member Status Time Action Last Update
MicBun ✅ Submitted 4h Update time Feb 24, 2026, 12:26 PM

You can submit time with the command. Example:

@holdex pr submit-time 15m

See available commands to help comply with our Guidelines.

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: 1

🧹 Nitpick comments (1)
examples/decode_market_example/main.py (1)

61-63: Guard thresholds formatting against non-string values.

If thresholds contains numbers, ", ".join(...) will raise a TypeError. Converting to strings keeps the example resilient.

♻️ Suggested tweak
-                    thresholds_str = ", ".join(details['thresholds'])
+                    thresholds = details.get("thresholds", [])
+                    thresholds_str = ", ".join(map(str, thresholds))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/decode_market_example/main.py` around lines 61 - 63, The join call
on details['thresholds'] can raise TypeError if elements are non-strings; update
the formatting in the block that builds thresholds_str (where thresholds_str =
", ".join(details['thresholds']) and the subsequent print) to coerce each
threshold to a string first (e.g., use map(str, details['thresholds']) or a
comprehension) and optionally handle a missing or non-iterable thresholds value
by defaulting to an empty list so the print still works.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/decode_market_example/main.py`:
- Around line 67-68: Replace the broad except Exception handler that prints
errors for each market with a narrowed exception tuple: catch RuntimeError,
ValueError, and KeyError only (these come from get_market_info raising
RuntimeError, decode_market_data/json.loads raising ValueError, and accessing
market_info['query_components'] raising KeyError) and keep the existing error
logging/print for the caught exceptions so unexpected errors still surface.

---

Nitpick comments:
In `@examples/decode_market_example/main.py`:
- Around line 61-63: The join call on details['thresholds'] can raise TypeError
if elements are non-strings; update the formatting in the block that builds
thresholds_str (where thresholds_str = ", ".join(details['thresholds']) and the
subsequent print) to coerce each threshold to a string first (e.g., use map(str,
details['thresholds']) or a comprehension) and optionally handle a missing or
non-iterable thresholds value by defaulting to an empty list so the print still
works.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88e637e and 57e15ef.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • examples/decode_market_example/main.py
  • go.mod

Comment on lines +67 to +68
except Exception as e:
print(f" [!] Error processing market {market_id}: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Locate SDK exception types and what get_market_info/decode_market_data raise
rg -n --type=py "def get_market_info" -C5
rg -n --type=py "def decode_market_data" -C5
rg -n --type=py "class .*Error|Exception" -C3
rg -n --type=py "raise " -C2

Repository: trufnetwork/sdk-py

Length of output: 50376


🏁 Script executed:

#!/bin/bash
# Get the full decode_market_data implementation
sed -n '2736,2780p' src/trufnetwork_sdk_py/client.py

# Check if there are any custom exception classes defined
rg -n "^class.*Exception|^class.*Error" src/trufnetwork_sdk_py/ --type=py

# Get the complete context around lines 67-68 in the example file
sed -n '50,75p' examples/decode_market_example/main.py

# Search for what decode_market_data might raise
rg -n "def decode_market_data" -A 20 src/trufnetwork_sdk_py/ --type=py

Repository: trufnetwork/sdk-py

Length of output: 4509


🏁 Script executed:

#!/bin/bash
# Search for custom exception/error class definitions
rg -n "^class.*Exception|^class.*Error" src/trufnetwork_sdk_py/ --type=py

# Check for any documented exceptions in docstrings
rg -n "Raises:" src/trufnetwork_sdk_py/client.py -A 3 | head -50

Repository: trufnetwork/sdk-py

Length of output: 1285


Narrow broad Exception to specific SDK exception types.

The code should catch (RuntimeError, ValueError, KeyError) instead of bare Exception. get_market_info raises RuntimeError when a market isn't found, decode_market_data can raise ValueError (via json.loads), and accessing market_info['query_components'] can raise KeyError. Catching only these known exceptions prevents accidental masking of unexpected bugs.

🧰 Tools
🪛 Ruff (0.15.2)

[warning] 67-67: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/decode_market_example/main.py` around lines 67 - 68, Replace the
broad except Exception handler that prints errors for each market with a
narrowed exception tuple: catch RuntimeError, ValueError, and KeyError only
(these come from get_market_info raising RuntimeError,
decode_market_data/json.loads raising ValueError, and accessing
market_info['query_components'] raising KeyError) and keep the existing error
logging/print for the caught exceptions so unexpected errors still surface.

@MicBun MicBun merged commit 686f166 into main Feb 24, 2026
5 of 6 checks passed
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.

Problem: Can't get unsettled markets

1 participant