fix: harden get_active_listings input validation & edge cases (closes #120) - #291
Open
Obiajulu-gif wants to merge 2 commits into
Open
fix: harden get_active_listings input validation & edge cases (closes #120)#291Obiajulu-gif wants to merge 2 commits into
Obiajulu-gif wants to merge 2 commits into
Conversation
…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>
|
@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. |
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardened
get_active_listingsincontracts/marketplace/src/lib.rs:limit == 0now returns an empty vec immediately with an explicit early-return (documented in a comment) rather than relying on the loop'scount >= limitcheck to trivially exit.startalready yields an empty result via the existing loop logic; a stale active-id whoseListingrecord was removed is already skipped viaif let Some(l) = ...; a listing present in the active-ids index but withactive == falseis already filtered viaif l.active.Vec<Listing>return type rather than switching toResult<Vec<Listing>, MarketplaceError>— every edge case degrades gracefully to an empty/partial result, nothing can actually fail, so aResultwould be needless API churn for callers.contracts/marketplace/src/test.rscovering:limit == 0,startbeyond 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 buildfails 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 intest.rs. Please runcargo test -p automint-marketplacebefore merging.Target:
testnet-implementation(per the issue). Closes #120.Test plan
cargo test -p automint-marketplacepasses, including the 4 new edge-case tests