Hidden Assumptions in crystal
14 assumptions this code never checks · 6 critical · spanning Contract, Shape, Temporal, Ordering, Resource, Environment, Domain
Every codebase relies on things it never checks. Most of them are routine. CodeSea looked at graphile/crystal 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".
If setup() returns undefined or null, the contextFactory will receive undefined as setupResult, potentially causing runtime errors when accessing properties
If operation source contains malformed JSON5 in variableValues comment or uses different comment syntax, JSON5.parse() will throw and crash the benchmark
Type names with special characters, quotes, or newlines will generate invalid TypeScript code that fails compilation
Show everything (11 more)
The EventEmitter 'onPlan' event will always fire during operation execution, and the event payload will contain both 'elapsed' and 'laps' properties
If this fails: If the execution engine doesn't emit the expected event or emits with different payload structure, the timing object remains incomplete with undefined planning/laps data
grafast/bench/src/index.ts:bench
Schema types filtering assumes that all system types start with '__' and all built-in scalars are specified scalars, with no custom types following these naming conventions
If this fails: Custom types starting with '__' will be incorrectly filtered out, and custom scalars that happen to be specified scalars will be excluded from code generation
grafast/codegen-plugin/src/index.ts:GrafastGenerator.constructor
The `body` object passed to the middleware can be safely mutated by setting `body.query`, and downstream middleware expects this mutation
If this fails: If body is immutable or frozen, setting body.query will silently fail or throw, breaking persisted operation resolution
grafast/grafserv-persisted/src/index.ts:PersistedPlugin.middleware.processGraphQLRequestBody
When `realQuery` is a Promise, the Promise will always resolve to either a string or null/undefined, never reject or resolve to other types
If this fails: If the Promise resolves to an object, number, or other type, the typeof check fails and the code throws an incorrect 'provide document id' error instead of handling the actual data
grafast/grafserv-persisted/src/index.ts:persistedOperationFromPayload
The 'http-proxy' module, if installed, will have either `default.createProxyServer` or `createProxyServer` export, and dynamic import will either succeed completely or fail completely
If this fails: If http-proxy has different export structure or is partially corrupt, the function returns null instead of the proxy server, causing proxy features to silently fail
grafast/ruru/src/cli.ts:tryLoadHttpProxyCreateProxyServer
The `loadConfig` function can handle undefined configFileLocation and will not throw when the config file doesn't exist
If this fails: If loadConfig throws on missing files instead of returning null/undefined, the CLI crashes on startup when no config is specified
grafast/ruru/src/cli.ts:configFromArgs
ExecutionResult.errors, when defined, is always a non-empty array with each element having a 'message' property
If this fails: If errors is an empty array or contains objects without 'message' property, accessing errors[0].message will throw undefined access or property access errors
grafast/bench/src/index.ts:checkForErrors
The 'pg-sql2' module exists and is compatible with the expected interface, and require() will succeed in finding the module
If this fails: If pg-sql2 is missing, renamed, or has breaking changes, all PostgreSQL SQL construction fails at runtime with module not found errors
grafast/dataplan-pg/fwd/pg-sql2/index.js
The './thereCanBeOnlyOne.ts' import must execute before any other imports to properly establish singleton behavior
If this fails: If module loading order changes or thereCanBeOnlyOne has side effects that depend on timing, multiple instances of supposedly singleton objects may be created
grafast/grafast/src/index.ts
The 'grafast' module is available via require() and exports the exact functions makeGrafastSchema, lambda, and grafastSync
If this fails: In environments where ES modules are default or grafast is not installed, the example fails with module resolution or export access errors
grafast/website/examples/getting-started/index.js
This module is intended to be a runtime error for incorrect imports, but the error message assumes developers will understand the correct import paths
If this fails: New developers may be confused by the error and not understand they should import from 'ruru/server' or use 'ruru-components', leading to frustration
grafast/ruru/src/index.ts
See the full structural analysis of crystal: the pipeline, data models, and system behavior that put these assumptions in context.
Full analysis of graphile/crystal →Frequently Asked Questions
What does crystal assume that could break in production?
The one most likely to cause trouble: The `setup()` function returns an object that can be cast to `any` type when no specific setup is provided, and this object will be compatible with all `contextFactory` calls If this fails, If setup() returns undefined or null, the contextFactory will receive undefined as setupResult, potentially causing runtime errors when accessing properties
How many hidden assumptions does crystal have?
CodeSea found 14 assumptions crystal relies on but never validates, 6 of them critical, spanning Contract, Shape, Temporal, Ordering, Resource, Environment, Domain. 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.