Repository navigation
fix(#1528, #1543, #1566, #1568): shared cursor pagination primitive, with ELB, RAM, CodePipeline, CloudFront and IAM on it - #1679
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
4 tasks
RAM lists and pages on the entity alone; the two DescribeLoadBalancers generations bind distinct ops; CodePipeline and CloudFront load and filter before cutting the page, and a CloudFront store failure fails the list; filter values are a set; the zero key is a position; the simulate index comment is corrected; paging vars become funcs.
…e never ends on an empty NextMarker
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.
Fixes #1528
Fixes #1543
Fixes #1566
Fixes #1568
Part of #1612: this is the shared cursor pagination primitive. #1612's generated validation layer is the W-V workstream and is not in this PR.
The primitive
emulator/pagination.go:page[T](items []T, key func(T) cursorKey, req pageRequest) (pageResult[T], error).cursorKeyis{Sort, Tie}. The helper sorts a copy by key (ascending, or descending withreq.Descending) and resumes strictly after the decoded cursor, so a deleted cursor record resumes where it was.Truncatedis set only when a further item exists.pageAfter[T]is the same cut for raw-ID cursors, with no token. CloudFront and IAM use it.pageRequest.validate()decodes the token without reading any items. Each caller runs it before reading state.{"o":op,"h":fnv64a(filter),"s":sort,"t":tie}.his 16 hex digits over the canonical filter members: names sorted, values sorted as a set, empty values dropped, every string length-prefixed. A token is accepted only if its base64 and its JSON both round-trip byte for byte (no unknown, missing or reordered members) and itsoandhmatch the request. Every refusal wraps the sentinelerrPageToken, and each service maps it to its own code.pageSizeRange.check(v, refuse)applies the published bounds and renders the refusal through the service's error constructor.pagination_adapters.go:jsonNextToken(jsonPaging, filter, nextToken, maxResults)for RAM and CodePipeline;elbMarker(req, op, filter);iamMarker(req, maxItems, marker), which keeps IAM's existing base64-of-last-key cursor;restXMLMarker(req, def, invalid)for CloudFront's raw-IDMarker.queryMarkerPageis unchanged.Per issue
DescribeLoadBalancers,DescribeTargetGroups,DescribeListenersandDescribeRulesuse a value cursor in ARN order. ClassicDescribeLoadBalancersuses one in name order, and lists a name requested twice once. The twoDescribeLoadBalancersbind ops that carry the API version (DescribeLoadBalancers@2015-12-01and@2012-06-01), so neither accepts the other's marker.Names,*Arns,LoadBalancerArn,ListenerArnandLoadBalancerNames.PageSizeis 1–400 through the existingelbPageSize. A bad, foreign or filter-mismatched marker isValidationError/400, the Query Common Errors code that each operation links as its own.DescribeAccountLimitsstays on its offset; itsMQ==pins are untouched.ListPrincipalsandListResourceskey the cursor and the dedupe on the entity alone (principal ID or resource ARN) and render in that order. A principal or resource in several shares is listed once and carries the first share in ARN order as itsresourceShareArn.API_PrincipalandAPI_Resourcedescribe that member as "a resource share" the item is associated with, so any one of its shares is valid.maxResultsis 1–500,InvalidParameterException, unchanged.InvalidNextTokenException/400, using the pages' own wording, and is refused before any state is read.GetResourceShares'op:ARNtoken is not JSON, so both list operations refuse it, and GetResourceShares refuses theirs.ListPipelinesreadsmaxResultsandnextToken, using a name cursor. Both codes are published onAPI_ListPipelines:maxResultsoutside 1–1000 isValidationException/400;InvalidNextTokenException/400, with the page's gloss as the message.maxResultsis 1000, which is substrate's reading because the page publishes no default.ListDistributionsandListOriginAccessControlsread theMarkerandMaxItemsquery parameters and list in ID order.Marker,MaxItems,IsTruncatedandQuantity, plusNextMarker(the page's last ID) when truncated.MaxItemsdefaults to 100, substrate's reading, because neither page publishes a default. A value that is not a positive integer isInvalidArgument/400, the one code both pages publish.Markeris accepted. An unknown or deleted ID resumes after where it sorts.Getfailure fails the call; a dangling or undecodable record is passed over. Only the distributions on the page spend a status-countdown observation.ListInvalidations. Its page publishes a most-recent-first order with an ID marker, which needs a decision about ordering, so it is listed in pagination: migrate the remaining 80 mutable offset paginators to the cursor primitive, in protocol batches #1677.ListCachePoliciesand the other list operations are not routed.paginateIAMKeys(10 sites) andiamTagListingResponse(4 sites) now go throughiamMarker.Markerthat is not canonical base64 of a non-empty key isValidationError/400 (IAM CommonErrors: "The input doesn't meet the required format or constraints."), not page one.decodeSimulationMarkernow delegates todecodeOffsetPaginationToken. A bad marker onSimulatePrincipalPolicyorSimulateCustomPolicyisInvalidInput/400, published by both operations ("The request was rejected because an invalid or out-of-range value was supplied for an input parameter.").The refusal messages are substrate's own. No page publishes wording for them, except RAM's
InvalidNextTokenExceptionand CodePipeline's, which use the pages' text.Tests
pagination_test.go: table tests coveringelb_page_cursor_test.go: a mid-walk create and delete on v2 LBs, v2 TGs and classic, plus op and filter binding;ram_pagination_test.go: the order, a mid-walk disassociate, associate and share delete, and filter binding;codepipeline_list_pipelines_test.go;cloudfront_list_pagination_test.go;iam_marker_test.go: 12 listings refuse forged markers, and a ListUsers walk survives a mid-walk delete.elb_page_cursor_test.go: the past-the-end case is nowDescribeAccountLimitsonly;ram_pagination_test.go: the offset-clamp test is replaced by composite-cursor tests;iam_tagging_test.go:402: the marker is now base64 ofowner;iam_simulate_test.go: the tolerant-marker cases are now refusals.pagination_token_refusal_test.goand the other offset tests cover operations this PR does not migrate, and are unchanged.Routed-operation catalog unchanged (no operations added).
Gates run locally
make lint test e2eoperation-catalog-check docs-reference-check docs-headings-check operation-docs-check authz-reference-check cfn-schema-check doc-links-checkwire-bookkeeping-check discarded-unmarshal-check discarded-marshal-check discarded-state-check nondeterminism-check comment-history-checkdocs-versions,docs-counts-checkSUBSTRATE_IAC=1 make iac-e2e(Terraform journey and CDK journey, both pass)Patch functions are at 89–100% statement coverage. The uncovered lines are the
pageerror returns behind a token that was already validated.Review fixes (second commit)
["x","x"]hashes the same as["x"](tested).sandtalways, and it round-trips (tested). IAM keys are names, paths or ARNs with a published minimum length of 1, so none is empty.docs/reference/iam.mdare corrected: positions are fixed by the request, but SimulatePrincipalPolicy's decisions are not.Quantitynow precedesItems.LoadBalancerArn, which predates this PR and is too large to fix here.Follow-up
DescribeStackEvents, JSON ×28, REST-JSON ×26), plus CloudFrontListInvalidations. It also lists the 13 static sites that can stay on an offset.