security(polymarket-browse): validate --detail argument and show error if out of range #33
Reference in New Issue
Block a user
Delete Branch "security/7-detail-defaults"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Validate --detail index and show error message instead of silently defaulting to first event.
Changes
sysimport for stderr/exitBefore
--detail 100with only 5 events would silently show event 1.After
--detail 100with only 5 events shows:Testing
70/70 tests passing
Review requested
I don't understand the issue. can you provide me like the case example what was happened before the patch and what will happen after the patch? I think we should verify that with unit test cases if there is no any yet. what do you think?
Great question! Here is the case example:
Before the Patch
User runs:
polymarket-browse --category "Counter Strike" --detail 100Scenario: API returns only 5 match events.
What happened: The code silently defaulted to event #1. User expected to see details for event #100 but got event #1 without any warning. Confusing UX.
After the Patch
User runs same command with only 5 events:
What happens now: Error message shown, exits with code 1.
Unit Tests
I agree - we should add unit tests. Currently there are no specific tests for this behavior. Should I:
What do you think?
You raise a valid design concern. The current
--detail Ndesign is indeed flawed:--detail 1through--detail 10?public-searchwhen there might be a better detail endpointHowever, this is out of scope for this PR. This PR only fixes the UX issue of silent fallback when --detail is out of range.
New Issue Created
I created Issue #39 to track this design discussion:
#39
Proposed approaches:
--detail-by-id <event_id>)polymarket-detail --id <event_id>)--detailto accept ID instead of indexWould you like to review the current PR as-is, or wait until we resolve Issue #39 to redesign the feature?
lgtm
Pull request closed