Hidden Assumptions in commerce

12 assumptions this code never checks · 3 critical · spanning Domain, Contract, Shape, Environment, Temporal, Scale, Ordering, Resource

Every codebase relies on things it never checks. Most of them are routine. CodeSea looked at vercel/commerce and picked out the few most likely to cause trouble. The full list is just below.

Most of what this code assumes is routine. These 3 are the ones most likely to cause trouble here. The rest are minor; they're under "Show everything".

Worth your attention first

If the token is missing, expired, or revoked, all product fetching silently fails or returns unauthorized errors, making the entire store non-functional

Worth your attention first

If price contains '$12.99' instead of '12.99', Number() returns NaN and cart totals become NaN, breaking checkout calculations

Worth your attention first

If merchandise IDs have different formats or the cart structure changes, line items won't be found and removal operations silently fail, leaving stale items in cart

Show everything (9 more)
Environment

Shopify store has a menu handle named exactly 'next-js-frontend-header-menu' configured in the admin

If this fails: If the menu doesn't exist or is renamed, navigation returns empty array and the main menu disappears from the site without error

components/layout/navbar/index.tsx:getMenu
Temporal

Next.js cache tags remain valid and cache invalidation happens immediately when products or cart data changes in Shopify

If this fails: If cache invalidation fails or is delayed, users see stale product prices, availability, or cart contents that don't match Shopify's current state

lib/shopify/index.ts:shopifyFetch
Scale

Product images from Shopify are reasonably sized and the Next.js Image component can handle them without memory issues in grid layouts

If this fails: If products have massive high-resolution images, the grid page becomes slow to load and may cause browser memory issues with many products displayed

components/grid/tile.tsx:GridTileImage
Contract

All items in the list array have either SortFilterItem shape (with slug/title) or PathFilterItem shape (with title/path), never mixed or undefined

If this fails: If list contains items with unexpected shapes or null values, the filter rendering breaks and users can't sort or filter products

components/layout/search/filter/index.tsx:FilterItemList
Ordering

The cartPromise resolves before any cart operations (add/remove/update) are attempted by child components

If this fails: If cart operations fire while the initial cart is still loading, optimistic updates work but server actions may fail due to missing cart context

components/cart/cart-context.tsx:CartProvider
Domain

Products tagged with 'nextjs-frontend-hidden' in Shopify should be excluded from catalog display, and this tag name won't conflict with merchant's existing tags

If this fails: If merchants use this tag for other purposes or products get tagged accidentally, items disappear from the storefront unexpectedly

lib/constants.ts:HIDDEN_PRODUCT_TAG
Resource

Search queries are short enough to fit in URL parameters and don't contain characters that break Next.js routing

If this fails: If users search for very long strings or special characters, the navigation to /search may fail or produce invalid URLs

components/layout/navbar/search.tsx:Form
Environment

SITE_NAME environment variable is set and doesn't contain HTML or special characters that break metadata generation

If this fails: If SITE_NAME is missing or contains '<script>' tags, page titles become undefined or create XSS vulnerabilities in metadata

app/layout.tsx:SITE_NAME
Contract

All children passed to Grid are valid React elements that can be rendered as list items in a CSS grid layout

If this fails: If non-element children like strings or numbers are passed, the grid layout breaks and products don't display correctly

components/grid/index.tsx:Grid

See the full structural analysis of commerce: the pipeline, data models, and system behavior that put these assumptions in context.

Full analysis of vercel/commerce →

Compare commerce

Frequently Asked Questions

What does commerce assume that could break in production?

The one most likely to cause trouble: SHOPIFY_STOREFRONT_ACCESS_TOKEN environment variable exists and contains a valid token that won't expire during the app's lifetime If this fails, If the token is missing, expired, or revoked, all product fetching silently fails or returns unauthorized errors, making the entire store non-functional

How many hidden assumptions does commerce have?

CodeSea found 12 assumptions commerce relies on but never validates, 3 of them critical, spanning Domain, Contract, Shape, Environment, Temporal, Scale, Ordering, Resource. Most are routine — the analysis flags the two or three most likely to actually bite.

What is a hidden assumption?

Something the code depends on but never checks: a data shape, an ordering, an environment condition, a scale limit, or a contract with another service. It holds until the world it runs in changes, then fails silently.