prisma/prisma ยท error
Usage: pnpm start -- proximity-chain <t0> <d1> <t1> [<d2> <t
Error message
Usage: pnpm start -- proximity-chain <t0> <d1> <t1> [<d2> <t2> ...]
What it means
Thrown by parseProximityChainArgs in the paradedb-demo CLI when the argument count for the proximity-chain subcommand is wrong. It requires an odd count of at least 3 args (t0 d1 t1, optionally more d/t pairs), so any even count or fewer than 3 args triggers the usage error. This is the CLI's structural validation before any term/distance parsing.
Source
Thrown at examples/paradedb-demo/src/main.ts:19
import 'dotenv/config';
import { loadAppConfig } from './app-config';
import { ormClientBm25TopMatches } from './orm-client/bm25-top-matches';
import { db } from './prisma/db';
import { bm25CastDemo } from './queries/bm25-cast-demo';
import { bm25ChainDemo } from './queries/bm25-chain-demo';
import { bm25Fuzzy } from './queries/bm25-fuzzy';
import { bm25Match } from './queries/bm25-match';
import { bm25ModeTour } from './queries/bm25-mode-tour';
import { bm25Proximity } from './queries/bm25-proximity';
import { bm25ProximityChain, type ProximityChainStep } from './queries/bm25-proximity-chain';
import { bm25TopByScore } from './queries/bm25-top-by-score';
function parseProximityChainArgs(args: readonly string[]): {
readonly start: string;
readonly steps: readonly ProximityChainStep[];
} {
if (args.length < 3 || args.length % 2 !== 1) {
throw new Error('Usage: pnpm start -- proximity-chain <t0> <d1> <t1> [<d2> <t2> ...]');
}
const [start, ...rest] = args;
if (start === undefined) {
throw new Error('proximity-chain: <t0> is required');
}
const steps: ProximityChainStep[] = [];
for (let i = 0; i < rest.length; i += 2) {
const distRaw = rest[i];
const term = rest[i + 1];
if (distRaw === undefined || term === undefined) {
throw new Error(
`proximity-chain: trailing distance with no following term at position ${i + 1}`,
);
}
const ordered = distRaw.startsWith('>');
const distStr = ordered ? distRaw.slice(1) : distRaw;
const distance = Number.parseInt(distStr, 10);
if (!Number.isInteger(distance) || distance < 0) {View on GitHub (pinned to 1243cdffbe)
Solutions
- Provide an odd argument count >= 3: start term, then repeating distance+term pairs, e.g. `proximity-chain t0 1 t1`.
- Add the missing term at the end, or remove a dangling distance, so total args are odd.
- For longer chains, append pairs: `proximity-chain t0 1 t1 2 t2` (5 args).
- Re-read the usage line and count your tokens before retrying.
Example fix
// before $ pnpm start -- proximity-chain apples oranges // after $ pnpm start -- proximity-chain apples 2 oranges
Defensive patterns
Strategy: validation
Validate before calling
const args = process.argv.slice(2).filter((a) => a !== '--');
if (args.length < 3 || args.length % 2 !== 1) {
console.error('Usage: pnpm start -- proximity-chain <t0> <d1> <t1> [<d2> <t2> ...]');
process.exit(1);
}
// now safe to call parseProximityChainArgs(args) Type guard
const isProximityArgShape = (a: readonly unknown[]): a is [string, ...string[]] => a.length >= 3 && a.length % 2 === 1 && a.every((x) => typeof x === 'string');
Try / catch
try {
const { start, steps } = parseProximityChainArgs(args);
} catch (error) {
if (error instanceof Error && error.message.startsWith('Usage:')) {
console.error(error.message);
process.exit(1);
}
throw error;
} Prevention
- Pre-check arg count/parity at the CLI boundary so usage prints before any parsing runs.
- Use a dedicated arg parser (e.g. commander/yargs) with declared arity to get usage text for free.
- Treat the usage message as the contract: keep the README example in sync with it.
- Wrap parseProximityChainArgs in a try/catch that re-emits the usage string on any of its known errors.
When it happens
Trigger: Invoking `pnpm start -- proximity-chain ...` with fewer than 3 arguments or an even number of arguments. Examples: `proximity-chain foo`, `proximity-chain foo 1` (2 args), `proximity-chain foo 1 bar 2` (4 args).
Common situations: Omitting the trailing term, forgetting a distance, or pasting an incomplete chain. Users often try `proximity-chain term1 term2` expecting adjacency without specifying distances.
Related errors
- proximity-chain: distance at position ${i + 1} must be a non
- proximity-chain: <t0> is required
- proximity-chain: trailing distance with no following term at
- Invalid app configuration: ${message}
- embedding must be an array of numbers
AI-assisted analysis of prisma/prisma@1243cdffbe (2026-08-01).
Data as JSON: /data/errors/97fb93578503632a.json.
Report an issue: GitHub.