Repository navigation
fix(types): expose page/limit/totalPages on the paginated indicator surfaces - #5
Merged
Merged
Conversation
…urfaces
IoCsResponse, IndicatorsResponse and YaraRulesResponse modelled only items and
total. The API returns page, limit and totalPages on all three -- verified
against app.threat.zone, where /iocs?page=1&limit=5 answers
{items, total: 35, page: 1, limit: 5, totalPages: 7} -- and BehavioursResponse
has exposed the full envelope all along. Pydantic silently dropped the three
extra keys, so a caller could not page these endpoints without recomputing from
total what the service had already sent, and had no way to learn totalPages
existed.
The fake server had the same hole, which is why no test caught it: its builders
returned {items, total} and therefore agreed with the incomplete models rather
than with the API they stand in for. They now apply the documented defaults
(page 1, limit 20), slice accordingly and emit the whole envelope, so the
in-memory server pages like the real one.
Companion to the public-api docs fix: the guides for these three endpoints
omitted the same three fields.
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.
Found while integrating the Public API from an external client, verified against the live service with a real submission.
The gap
IoCsResponse,IndicatorsResponseandYaraRulesResponsemodel onlyitemsandtotal. The API returns the full envelope on all three:Pydantic silently drops the three extra keys, so a caller cannot page these endpoints without recomputing from
totalwhat the service already sent — and has no way to discovertotalPagesexists at all.BehavioursResponse(types/behaviours.py:42) has exposedpage,limitandtotal_pagesall along, so the SDK was inconsistent with itself.Why no test caught it
The in-memory fake had the same hole.
build_iocs_responseand friends returned{items, total}, so the fixtures agreed with the incomplete models rather than with the API they stand in for — a fake that reproduces the bug it should expose.The builders now apply the documented defaults (
page1,limit20), slice accordingly, and emit the whole envelope, so the fake pages like the real service.Changes
types/indicators.py— the three models gainpage,limit,total_pages(aliasedtotalPages), matchingBehavioursResponseexactly.testing/_responses.py— the three builders emit the full envelope and paginate.tests/conftest.py— the shared fixtures carry the fields the API actually sends.tests/test_types.py— asserts all three surfaces expose the envelope.Required rather than optional, matching the service DTOs (
indicators.response.dto.ts:126,211,259), which declare them non-optional, and matching the existingBehavioursResponseprecedent.Verification
607 tests pass,
ruff checkclean,mypyclean on 33 source files.Related
Companion to Malwation/threatzone-services#1455 — the guides for these same three endpoints omitted the same three fields, so the docs and the SDK were wrong in the same place.