Skip to content

Re-Add Variations Summary#49

Closed
Oakes6 wants to merge 4 commits into
goark:masterfrom
Oakes6:hotfix/page-count
Closed

Re-Add Variations Summary#49
Oakes6 wants to merge 4 commits into
goark:masterfrom
Oakes6:hotfix/page-count

Conversation

@Oakes6

@Oakes6 Oakes6 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Restore VariationSummary resource & fill in entity gaps surfaced by the Creators API SDK

Why

The Creators API migration mistakenly removed EnableVariationSummary() — The official Amazon SDK (get_variations_resource.py) explicitly enumerates:

  • variationSummary.price.highestPrice
  • variationSummary.price.lowestPrice
  • variationSummary.variationDimension

Because we never requested those resources, the response's variationSummary block was always empty — pageCount, variationCount, the price range, and the variation dimensions all came back nil even though the entity already had fields for them.

While auditing the rest of the SDK I also found a handful of smaller decode gaps that this PR cleans up at the same time.

Changes

Resource enable + plumbing

query/resources.go — re-added resourceVariationSummary with the three lowerCamelCase strings above.

query/query.goQuery.VariationSummary() is no longer a no-op; it sets the resource flag. The // Deprecated: comment is replaced with a description of the response block this resource populates.

Entity field gaps

entity/entity.go — five fixes uncovered while cross-checking each Creators API model against entity.Item:

Gap Fix
Images.Primary.HiRes and Images.Variants[].HiRes missing Added HiRes *Image \json:"hiRes,omitempty"`. The Creators API uses hiResin responses even though the resource enum isimages.primary.highRes` — quirk in the API itself, not a typo on our side.
VariationDimension.Locale missing Added Locale string.
BrowseNodeInfo.BrowseNodes[].WebsiteSalesRank.Id missing Added Id string \json:"id,omitempty"``.
Top-level BrowseNodesResult.BrowseNodes[].SalesRank missing Added SalesRank *int.
OffersV2.Listings[].ViolateMAP decoded the wrong key Renamed to ViolatesMAP with explicit \json:"violatesMAP,omitempty"`tag. The previous field was a typo carried over from PA-API v5; the Creators API actually returnsviolatesMAP` (with the "s").

Tests

entity/entity_test.go (new) — focused decode tests asserting all of the above end-to-end:

  • pageCount, variationCount, price.highestPrice/lowestPrice, variationDimensions[].locale populate from a Creators API GetVariations payload.
  • images.primary.hiRes, isBuyBoxWinner, violatesMAP populate on items / V2 listings.
  • Top-level browseNodes[].salesRank and websiteSalesRank.id populate.
  • Regression check that unknown JSON keys don't break decode (so future API additions are forward-compatible).

query/query_test.go, query/getvariations_test.goEnableVariationSummary() expectation flipped from {} to the three resource strings.

Docs

README.md — removed the now-incorrect "no-op (resource is not exposed)" row for EnableVariationSummary from the legacy-fields table.

Verification

  • go build ./... clean.
  • go vet ./... clean.
  • go test -count=1 -race ./... passes (root, entity, query).

Migration impact

  • No behavior change required for callers already invoking q.EnableVariationSummary() — they were getting silent nils, now they get populated data.
  • OffersV2.Listings[].ViolateMAP field rename to ViolatesMAP is a minor source-level break for anyone reading that field directly. Trade-off: the previous name never decoded the new API's payload anyway, so callers reading it were always seeing false regardless of the actual offer status. Renaming is the correct fix.

Risk / rollback

Low. Reverting puts EnableVariationSummary() back to a no-op (the bug we're fixing) and restores the broken ViolateMAP decode, so rollback is only useful if the new resource string somehow misbehaves at the API — which is verifiable with a single live GetVariations call. Forward-fix is preferable.

@Oakes6

Oakes6 commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@spiegel-im-spiegel patching latest release to include neglected entity fields

@spiegel-im-spiegel

Copy link
Copy Markdown
Member

Thanks again for the contribution. Based on the latest review, here is the proposed split plan.

Important update: we do not need to keep ViolateMAP for backward compatibility. It appears to be a typo from older docs, so we should standardize on ViolatesMAP only.

Proposed split:

  1. PR A: safe migration fixes (merge first)
  • Restore VariationSummary resource wiring and tests.
  • Keep additive entity decode fixes that align with current Creators API payloads.
  • Keep itemResults decoding compatibility.
  • Use ViolatesMAP only (drop ViolateMAP).
  1. PR B: behavior and shape adjustments (review separately)
  • Any field removals or contract-tightening changes.
  • Any resource-scope reductions (for example image resource contractions).
  • Any test rewrites that change expected behavior rather than validating migration compatibility.

This keeps PR A low-risk and easy to validate, while giving PR B focused review with explicit migration notes and evidence.

@spiegel-im-spiegel

Copy link
Copy Markdown
Member

I opened PR #50 as the PR-A extraction derived from this PR (#49): #50

It contains only the low-risk migration-compatible subset so we can merge safe fixes first, while keeping higher-risk behavior/shape changes for a separate PR-B review.

@spiegel-im-spiegel

Copy link
Copy Markdown
Member

Update: the safe subset has now been merged via PR #50.

We can continue reviewing the remaining higher-risk behavior/shape changes separately as PR-B.

@Oakes6

Oakes6 commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@spiegel-im-spiegel Sounds good! Will reopen a PR for those changes.

@Oakes6 Oakes6 closed this May 7, 2026
@Oakes6 Oakes6 mentioned this pull request May 7, 2026
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.

2 participants