Skip to content

fix: harden get_active_listings input validation & edge cases (closes #120) - #291

Open
Obiajulu-gif wants to merge 2 commits into
Ada-Girly881:testnet-implementationfrom
Obiajulu-gif:fix/issue-120-split
Open

fix: harden get_active_listings input validation & edge cases (closes #120)#291
Obiajulu-gif wants to merge 2 commits into
Ada-Girly881:testnet-implementationfrom
Obiajulu-gif:fix/issue-120-split

Conversation

@Obiajulu-gif

Copy link
Copy Markdown
Contributor

Summary

Hardened get_active_listings in contracts/marketplace/src/lib.rs:

  • limit == 0 now returns an empty vec immediately with an explicit early-return (documented in a comment) rather than relying on the loop's count >= limit check to trivially exit.
  • Confirmed by reading the code (not assumed): an out-of-range start already yields an empty result via the existing loop logic; a stale active-id whose Listing record was removed is already skipped via if let Some(l) = ...; a listing present in the active-ids index but with active == false is already filtered via if l.active.
  • Kept the Vec<Listing> return type rather than switching to Result<Vec<Listing>, MarketplaceError> — every edge case degrades gracefully to an empty/partial result, nothing can actually fail, so a Result would be needless API churn for callers.
  • Added tests in contracts/marketplace/src/test.rs covering: limit == 0, start beyond the active-listings count, a stale active-id with a removed listing record, and an inactive-but-indexed listing.

Verification caveat: this Windows environment has no working MSVC linker (confirmed: cargo build fails at the link step for even proc-macro build scripts), so I could not compile or run these tests. Written by close pattern-matching against the existing test harness conventions in test.rs. Please run cargo test -p automint-marketplace before merging.

Target: testnet-implementation (per the issue). Closes #120.

Test plan

  • cargo test -p automint-marketplace passes, including the 4 new edge-case tests

…cases

Add explicit limit==0 early-return, document graceful degradation for
out-of-range start, stale index entries, and inactive-but-indexed
listings. Keep Vec<Listing> return type since no edge case can fail.
Add tests covering all four cases; fix two pre-existing zero-arg
get_active_listings() calls in test.rs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Obiajulu-gif is attempting to deploy a commit to the Ada's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Obiajulu-gif Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add input validation & edge case handling for get_active_listings in the marketplace contract

1 participant