Hidden Assumptions in berry

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

Every codebase relies on things it never checks. Most of them are routine. CodeSea looked at yarnpkg/berry 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 both require() and Proxy are unavailable (e.g., restricted environments), the CLI fails silently or throws confusing 'Dynamic require not supported' errors instead of clear environment compatibility messages

Worth your attention first

If __dirname is undefined (ES modules) or points to a virtual/network path that npath.toPortablePath cannot handle, test fixtures fail to load with path conversion errors

Worth your attention first

If rawManifest has non-enumerable properties, frozen objects, or dependency values that aren't strings, catalog resolution fails with TypeError during workspace packing

Show everything (9 more)
Resource

Assumes https://repo.yarnpkg.com/tags endpoint is always available and returns JSON with expected latest.stable/latest.canary structure

If this fails: If the endpoint is down, returns non-JSON, or changes schema, version display shows '...' indefinitely without user feedback about the failure

packages/docusaurus/src/pages/index.tsx:35
Temporal

Uses ThrowReport for catalog resolution during packing, assuming all catalog references can be resolved synchronously without network calls

If this fails: If catalog resolution requires fetching remote packages or waiting for cache validation, packing fails with uncaught exceptions instead of proper async error handling

packages/plugin-catalog/sources/index.ts:ThrowReport
Shape

PATCHES Map assumes dependency.identHash exists and getPatch() returns string|undefined, but dependency structure isn't validated

If this fails: If dependency object lacks identHash property or patch functions return unexpected types, reduceDependency silently creates malformed patch descriptors

packages/plugin-compat/sources/index.ts:PATCHES.get
Ordering

Assumes project.loadUserConfig() and engine.process() execute in correct sequence, but doesn't handle race conditions if multiple validation hooks run concurrently

If this fails: Concurrent constraint validations could interfere with each other, leading to inconsistent constraint check results or corrupted project state

packages/plugin-constraints/sources/index.ts:validateProjectAfterInstall
Environment

Imports isCI from ci-info package assuming it correctly detects all CI environments, but CI detection logic may not cover custom or corporate CI systems

If this fails: Commands behave differently in unrecognized CI environments - might show interactive prompts in CI or skip CI-specific validations in actual CI systems

packages/plugin-essentials/sources/index.ts:isCI
Scale

Constraint validation assumes error collection fits in memory and can be iterated synchronously, with no limits on error count

If this fails: Projects with thousands of constraint violations could exhaust memory during error collection or cause UI to become unresponsive while displaying all errors

packages/plugin-constraints/sources/index.ts:remainingErrors.size
Contract

Assumes Manifest.allDependencies contains all possible dependency section names and that each section in rawManifest is an object with string keys

If this fails: If new dependency types are added to package.json spec or sections contain non-string keys (like symbols), catalog processing silently skips them without warning

packages/plugin-catalog/sources/index.ts:Manifest.allDependencies
Domain

Assumes all feature icons exist as PNG files at /img/{icon}.png with exactly 200x180 dimensions

If this fails: Missing icon files cause broken images on homepage; wrong dimensions break responsive layout design

packages/docusaurus/src/components/HomepageFeatures/index.tsx:45
Temporal

Version fetching assumes component unmounting doesn't happen during async fetch, potentially causing setState on unmounted component

If this fails: React warnings about memory leaks if user navigates away before version fetch completes

packages/docusaurus/src/pages/index.tsx:Promise.resolve().then

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

Full analysis of yarnpkg/berry →

Frequently Asked Questions

What does berry assume that could break in production?

The one most likely to cause trouble: Script assumes Node.js environment supports dynamic require() but falls back to Proxy-based module loading without validating either approach will work If this fails, If both require() and Proxy are unavailable (e.g., restricted environments), the CLI fails silently or throws confusing 'Dynamic require not supported' errors instead of clear environment compatibility messages

How many hidden assumptions does berry have?

CodeSea found 12 assumptions berry relies on but never validates, 4 of them critical, spanning Environment, Domain, Contract, Resource, Temporal, Shape, Ordering, Scale. 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.