drizzle-team/drizzle-orm · error · Error
weighted values arrays is too small to generate values with
Error message
weighted values arrays is too small to generate values with specified probability for unique not null column.it's planned to generate: ${...} What it means
Error "weighted values arrays is too small to generate values with specified probability for unique not null column.it's planned to generate: ${...}" thrown in drizzle-team/drizzle-orm.
Source
Thrown at drizzle-seed/src/services/Generators.ts:308
const values = params.values;
let valuesWeightedIndices;
if (isObject(values[0])) {
valuesWeightedIndices = getWeightedIndices((values as { weight: number }[]).map((val) => val.weight));
if (isUnique === true && notNull === true) {
let idx: number, valueIdx: number, rng = prand.xoroshiro128plus(seed);
const indicesCounter: { [key: number]: number } = {};
for (let i = 0; i < count; i++) {
[idx, rng] = prand.uniformIntDistribution(0, valuesWeightedIndices.length - 1, rng);
valueIdx = valuesWeightedIndices[idx]!;
if (!Object.hasOwn(indicesCounter, valueIdx)) indicesCounter[valueIdx] = 0;
indicesCounter[valueIdx]! += 1;
}
for (const [idx, value] of values.entries()) {
if ((value as { values: (number | string | boolean | undefined)[] }).values.length < indicesCounter[idx]!) {
throw new Error(
'weighted values arrays is too small to generate values with specified probability for unique not null column.'
+ `it's planned to generate: ${
Object.entries(indicesCounter).map(([idx, count]) => {
return `${count} values with probability ${(values as { weight: number }[])[Number(idx)]?.weight}`;
}).join(',')
}`,
);
}
}
}
}
if (isUnique === true && maxRepeatedValuesCount === undefined) {
maxRepeatedValuesCount = 1;
}
let genMaxRepeatedValuesCount: GenerateDefault | GenerateWeightedCount | undefined;
if (typeof maxRepeatedValuesCount === 'number') {
genMaxRepeatedValuesCount = new GenerateDefault({ defaultValue: maxRepeatedValuesCount });
} else if (typeof maxRepeatedValuesCount === 'object') {View on GitHub (pinned to b7862528fd)
Solutions
- Add more weighted values, lower the requested count/probability, or relax the unique/notNull constraints on the column.
When it happens
Trigger: Weighted values arrays are too small to satisfy the requested generation count/probability for a unique not-null column.
Common situations: Small weighted candidate pools combined with large seed counts; probabilities forcing reuse of unique values.
AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03).
Data as JSON: /data/errors/c4a66cd56e52acad.json.
Report an issue: GitHub.