chore: update sdk-go depedencies for viewing unsettled market#103
chore: update sdk-go depedencies for viewing unsettled market#103
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors 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 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Time Submission Status
You can submit time with the command. Example: See available commands to help comply with our Guidelines. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/decode_market_example/main.py (1)
61-63: Guard thresholds formatting against non-string values.If
thresholdscontains numbers,", ".join(...)will raise aTypeError. 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
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (2)
examples/decode_market_example/main.pygo.mod
| except Exception as e: | ||
| print(f" [!] Error processing market {market_id}: {e}") |
There was a problem hiding this comment.
🧩 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 " -C2Repository: 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=pyRepository: 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 -50Repository: 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.
resolves: #101
Summary by CodeRabbit
New Features
Chores