Repository navigation
Conversation
Neither `cargo check` nor `cargo test` gets anywhere on main - the library fails
first, and the test targets have never been compiled at all (verified with the
pinned 1.89.0 toolchain).
Library errors:
- src/event.rs - `Event` derives Serialize/Deserialize over `DateTime<Utc>`, but
chrono was pulled in without its `serde` feature, so those bounds were never
satisfiable;
- src/lib.rs - `AppState` derives `Clone` while holding a governor
`RateLimiter`, which is not `Clone`, so every handler failed the bound.
Test targets, which only surfaced once the library compiled:
- `tower` was declared without the `util` feature, so every
`ServiceExt::oneshot` in tests/handler_integration_tests.rs failed to resolve;
- tests/{hash_validation,rate_limit,revoke}.rs construct an AppState, so they
need the same `Arc::new` around the limiter;
- src/stellar.rs' mock put `data_key` into a `json!` body and then asserted on it
again, borrowing after a move.
Verified: `cargo test --no-run` compiles every target, and
`cargo test --no-fail-fast` now runs the whole suite. 12 tests fail there
(the library target and tests/revoke.rs) - all of them pre-existing failures in
test code that was unreachable until now, none of them touched here.
…y response
The issue is that a document with a long history is served in one unbounded
response. The module meant to prevent that already exists in main
(`module/ownership_chain/pagination.rs`) but nothing calls it: it is not
declared in its own mod.rs, its `Page` type is not serializable, and no handler
uses it - dead code, which is why the endpoint still returns the whole chain.
What this does:
- declares the module and makes `Page<T>` serializable;
- hardens `paginate`: a cursor past the end is an empty page rather than a
panic, and a page size of zero cannot return a cursor that never advances;
- moves the page-size limits into the pagination module (default 50, cap 200) so
both history handlers share them instead of one of them owning them;
- wires the endpoint: `GET /verify/:hash/history?cursor=&page_size=` now serves
a bounded page, and the response carries `total` and `next_cursor` so a client
can walk the chain to the end.
Note for the reviewer: this repository has two `app()` functions and two copies
of `verify_document_history` (src/lib.rs and src/{routes,handlers/verify}.rs).
The one the binary and the tests actually use is src/lib.rs' - I found that the
hard way, because paginating only the handlers/ copy left the endpoint's
behaviour unchanged. Both copies are kept in step here; consolidating them is a
separate job.
Tests: 7 unit tests over the `paginate` boundaries (first/middle/last page, a
page that covers the remainder, a cursor past the end, a zero page size, an
empty chain) and 3 endpoint tests over a seeded 5-record chain (page 1 then page
2 then the final page with a null cursor), a 300-record chain with
`page_size=10000` (clamped to 200 server-side), and no query string at all
(the documented default).
Contributor
|
@jarik2014 is attempting to deploy a commit to the Mftee's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Issue has been completed by another contributor (@lynaDev2) and points awarded. Closing this PR as redundant. |
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.
Closes #1346.
What the issue actually is
module/ownership_chain/pagination.rsis already inmain— it was added in #1401 — but nothing calls it: it is not declared in its ownmod.rs, itsPage<T>type is not serializable, and no handler uses it. Dead code. That is why the endpoint still returns a whole ownership chain in one response, and it is why fixing this needed no new pagination logic, only wiring and a hardening pass.The change
Page<T>serializable;paginate: a cursor past the end is an empty page rather than a panic onitems[cursor..end], and a page size of zero can no longer return a cursor that never advances (an infinite loop for a client that follows cursors);GET /verify/:hash/history?cursor=&page_size=serves a bounded page and the response carriestotalandnext_cursor, so a client can walk a long chain to the end.countkeeps its old meaning of "records in this response", which is now the page rather than the whole chain.Verified
Whole suite on this branch (all targets, which is itself new — see below):
The 12 failures are pre-existing test-code failures in modules this PR does not touch (
hash_validatornon-ASCII cases,stellarhttpmock cases,webhook, and one intests/revoke.rs). They were unreachable until now because the crate did not compile at all — see the first commit, which is a prerequisite rather than part of this issue.The first commit is a compile fix, not part of the issue
cargo checkandcargo testboth fail onmainbefore a single test runs, and the test targets had never been compiled. Fixing it is what makes any test of this issue possible, so it is split out and reviewable on its own:chronowas pulled in without itsserdefeature whileEventderives serde overDateTime<Utc>;AppStatederivesClonewhile holding a governorRateLimiter, which is notClone(now behind anArc);towerwas declared withoututil, so noServiceExt::oneshotin the integration tests resolved; three test files constructAppStateand needed the sameArc; andsrc/stellar.rs's mock borroweddata_keyafter moving it into ajson!body.One thing worth knowing before you review
This repository has two
app()functions and two copies ofverify_document_history: one pair insrc/lib.rs, another insrc/routes.rs+src/handlers/verify.rs. The binary and the tests use thelib.rsone (main.rsimportsstellar_doc_verifier::app), and I found that out the hard way: paginating only thehandlers/copy left the endpoint's behaviour unchanged, because the route table that actually serves traffic points at the other one. Both copies are kept in step here, including the sharedHistoryQuerytype, but consolidating the duplicates is a separate job I did not want to fold into this PR.Could you assign this issue to me in Drips? The wave only credits the assigned applicant, and I have applied for it.
About the red Vercel check: it fails with "Authorization required to deploy" — Vercel will not deploy a fork without the maintainer authorising it, so that check cannot pass from here and is unrelated to this change. What did pass on this PR: the Rust build and test jobs for the contract crate.