Repository navigation
Conversation
…uplicate checks are not capped at 10
This branch has not been deployed
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 #18498
What does this PR do?
plugin-ecommerceread two join fields without passing alimit, so both fell back to the database adapter's join default (field.defaultLimit ?? 10in@payloadcms/drizzle). Past 10 rows the plugin silently worked with an incomplete list:VariantOptionsSelectorloaded each variant type'soptionsjoin with onlysort: 'value', so only the first 10 options of a type were ever offered in the admin UI.validateOptionsloaded the product'svariantsjoin with no limit and checked the incoming combination againstproduct.variants.docs, so a combination already used by an 11th or later variant passed validation and could be saved twice. The selector's client-side duplicate warning (ErrorBox, fed by the same product read) had the same blind spot.Following the issue's suggested fix, this passes an explicit
limit: 0(unbounded, already supported by the adapters) at all three call sites:ui/VariantOptionsSelector/index.tsx— the variant-typeoptionsjoinui/VariantOptionsSelector/index.tsx— the product read feedingErrorBoxnow passesjoins: { variants: { limit: 0 } }collections/variants/createVariantsCollection/hooks/validateOptions.ts— the siblingvariantsjoinRelated fix in the same file (called out as "minor, related" in #18498)
validateOptionslooked up all four of its messages under theecommerce:namespace (variantOptionsRequired,productRequired,variantOptionsRequiredAll,variantOptionsAlreadyExists), but the plugin registers its translations only underplugin-ecommerce:(see the merge insrc/index.ts), so none of them resolved — the server logskey not found: ecommerce:variantOptionsAlreadyExistsand callers only ever get the generic field error. All four keys exist in the plugin's translations, and this was the only file using the wrong prefix, so the namespace is corrected for all four.Verification
Reproduced and verified end-to-end with the reporter's own repro repo (https://github.com/klaatu-code/payload-ecommerce-variant-limit-repro, SQLite, published
@payloadcms/plugin-ecommerce3.90.2):bug1=REPRODUCED bug2=REPRODUCED— selector query offers 10 of 12 options (white/yellowmissing), validator compares against 10 of 11 variants, a duplicate of the oldest variant is saved, andkey not found: ecommerce:variantOptionsAlreadyExistsis logged.validateOptionshook even when the caller uses the old query, and thekey not foundlog is gone. Control case (duplicate of a visible sibling) is rejected both before and after.Also adds an integration test in
test/plugin-ecommerce/int.spec.tsthat creates a product with 11 variants and asserts a duplicate of every existing combination is rejected, cleaning up after itself (the suite shares state).Not run locally: the monorepo integration suite (requires a full
pnpm install+ core build, not available in my environment) — the new test follows the suite's existing fixture/seed patterns and CI is authoritative for it. The changed files are Prettier-clean under the repo's.prettierrc.json.Disclosure: this fix was prepared with AI assistance; all verification output above is from real runs of the reporter's repro.
Fix offered freely — tips welcome, never required: PayPal [email protected] · BTC 3GnR7TWBXAB3pPztBWpNF4LMNEX5yX8vZK · ETH 0xA1d3CEB7bD707847c3c6aB59d30D385FE8DD85Fc · SOL DLg1ua1ufewQ81J7dQomwWhXzhZreq4jEwTaQJR31Exb — GitHub @Kshot3000, X @Kshot9000