Hidden Assumptions in refine

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

Every codebase relies on things it never checks. Most of them are routine. CodeSea looked at refinedev/refine 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 either payload.ids or params.ids is not an array (e.g., string, null, object), the .map() and .includes() calls will throw TypeError at runtime, causing live subscriptions to crash

Worth your attention first

If Ably delivers malformed messages without a type field, types.includes(message.data.type) throws TypeError, breaking live data synchronization for all subscribers on that channel

Worth your attention first

If auth provider returns null, undefined, or an object without redirectTo, the component may attempt to redirect to undefined URL or fail to redirect at all, leaving users in broken authentication state

Show everything (11 more)
Ordering

Assumes mutation status transitions follow idle → pending → success/error sequence, but switch statement has no validation of status values

If this fails: If mutation library provides unexpected status values (e.g., 'loading', 'cancelled', null), component falls back to idle state, hiding actual save progress from users and causing confusion about data persistence

packages/core/src/components/autoSaveIndicator/index.tsx:AutoSaveIndicator
Resource

Assumes telemetryHook() can always execute successfully during postAction hook, but provides no error handling

If this fails: If telemetry service is down, network is offline, or user has restrictive firewall, unhandled telemetry errors could crash CLI commands after successful completion, making tools appear unreliable

packages/cli/src/cli.ts:bootstrap
Environment

Assumes isGitClean.sync() will only throw errors for 'Not a git repository', but catches all errors and treats them as clean repository

If this fails: If git command fails due to permissions, corruption, or missing git binary, codemod proceeds thinking repo is clean, potentially overwriting uncommitted changes in broken git repositories

packages/codemod/src/index.ts:checkGitStatus
Scale

Assumes breadcrumb arrays will be reasonably small (minItems=2 default), but has no upper limit check on breadcrumbs.length

If this fails: For deeply nested routes with 50+ breadcrumb levels, component renders massive breadcrumb trail that breaks UI layout and makes navigation unusable, with no truncation or overflow handling

packages/antd/src/components/breadcrumb/index.tsx:Breadcrumb
Domain

Assumes event.channel is a valid Ably channel name following Ably's naming conventions (no validation of channel name format)

If this fails: If application passes invalid channel names with spaces, special characters, or exceeding length limits, Ably SDK throws errors that propagate to UI, breaking live data publishing for affected resources

packages/ably/src/index.ts:liveProvider.publish
Temporal

Assumes channelInstance from subscribe return value is still valid when unsubscribe is called, but channels can be detached or garbage collected

If this fails: If channel becomes detached between subscribe/unsubscribe calls, channelInstance.unsubscribe() may fail silently or throw, leaving ghost event listeners that continue consuming memory and processing irrelevant events

packages/ably/src/index.ts:liveProvider.unsubscribe
Contract

Assumes useIsAuthenticated hook always returns data object with authenticated property, but destructures data directly without null checks

If this fails: If auth provider hook returns null/undefined instead of {authenticated: boolean}, component crashes with 'Cannot destructure property authenticated of undefined', breaking route protection entirely

packages/core/src/components/authenticated/index.tsx:useIsAuthenticated
Shape

Assumes matchResourceFromRoute always returns object with found property, but accesses rootRouteResource.found without null checking rootRouteResource

If this fails: If route matching fails and returns null, accessing rootRouteResource.found throws TypeError, preventing breadcrumb rendering and potentially crashing the entire navigation component

packages/chakra-ui/src/components/breadcrumb/index.tsx:matchResourceFromRoute
Resource

Assumes jscodeshift executable and transformer files exist at computed paths, but only checks require.resolve for jscodeshift binary

If this fails: If transformer files are missing from dist/transformations directory after build, transformation fails with cryptic 'module not found' errors instead of helpful messages, leaving developers unable to run migrations

packages/codemod/src/index.ts:runTransform
Ordering

Assumes availableIntegrations.find() will return integration object with runTransformer method, but doesn't validate the method exists before calling

If this fails: If integration definition is incomplete or malformed, integration.runTransformer() throws 'is not a function' error, causing add command to fail after user selection without clear indication of configuration issue

packages/cli/src/commands/add/index.ts:addCommandAction
Environment

Assumes printAnnouncements() async function will always resolve successfully, but calls await without error handling

If this fails: If announcement service is unreachable or returns malformed data, dev command fails to start due to unhandled promise rejection, blocking local development when announcement feature should be non-critical

packages/cli/src/cli.ts:printAnnouncements

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

Full analysis of refinedev/refine →

Frequently Asked Questions

What does refine assume that could break in production?

The one most likely to cause trouble: Assumes message.data.payload.ids is an array when filtering created events, and that params.ids is also an array, but only checks if both are !== undefined rather than verifying array types If this fails, If either payload.ids or params.ids is not an array (e.g., string, null, object), the .map() and .includes() calls will throw TypeError at runtime, causing live subscriptions to crash

How many hidden assumptions does refine have?

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