n8n-io/n8n · error · InsertValuesMissingError
Cannot perform insert query because values are not defined.
Error message
Cannot perform insert query because values are not defined. Call "qb.values(...)" method to specify inserted values.
What it means
InsertQueryBuilder.getValueSets() throws InsertValuesMissingError when expressionMap.valuesSet is neither an array nor a plain object (it is undefined/null). This means .values(...) was never called, so there is nothing to insert. The guard runs during query creation, before SQL is emitted.
Source
Thrown at packages/@n8n/typeorm/src/query-builder/InsertQueryBuilder.ts:720
} else {
expression += ', ';
}
});
});
if (expression === '()') return '';
return expression;
}
}
/**
* Gets array of values need to be inserted into the target table.
*/
protected getValueSets(): ObjectLiteral[] {
if (Array.isArray(this.expressionMap.valuesSet)) return this.expressionMap.valuesSet;
if (ObjectUtils.isObject(this.expressionMap.valuesSet)) return [this.expressionMap.valuesSet];
throw new InsertValuesMissingError();
}
/**
* Checks if column is an auto-generated primary key, but the current insertion specifies a value for it.
*
* @param column
*/
protected isOverridingAutoIncrementBehavior(column: ColumnMetadata): boolean {
return (
column.isPrimary &&
column.isGenerated &&
column.generationStrategy === 'increment' &&
this.getValueSets().some(
(valueSet) =>
column.getEntityValue(valueSet) !== undefined && column.getEntityValue(valueSet) !== null,
)
);
}View on GitHub (pinned to 5ac6606e81)
Solutions
- Always call .values(objectOrArray) between .into() and .execute().
- Guard the insert behind a truthiness check on the payload before chaining.
- Default the payload to an empty object and validate required fields separately if you want a no-op to be explicit.
- Use repository.insert(payload) which surfaces the same requirement more clearly.
Example fix
// before
await dataSource.createQueryBuilder()
.insert().into(User) // .values(...) missing
.execute();
// after
if (!payload) throw new Error('payload required');
await dataSource.createQueryBuilder()
.insert().into(User).values(payload)
.execute(); Defensive patterns
Strategy: validation
Validate before calling
function hasInsertPayload(values: unknown): values is object | object[] {
return values != null && (Array.isArray(values) ? values.length > 0 : typeof values === 'object');
}
if (!hasInsertPayload(payload)) throw new Error('insert payload is required'); Type guard
function isNonEmptyInsertPayload(v: unknown): v is object | object[] {
if (Array.isArray(v)) return v.length > 0 && v.every(x => x && typeof x === 'object');
return v != null && typeof v === 'object';
} Prevention
- Always chain .values(payload) after .into() on insert builders.
- Guard the insert behind a truthiness check on the payload.
- Prefer repository.insert(payload) for clarity.
- Add a runtime assertion in shared insert helpers that payload is non-null.
When it happens
Trigger: Calling insert().into(Entity).execute() (or .getQuery()) without a preceding .values({...}). Also when .values() is called with undefined, e.g. a variable that resolved to undefined at runtime.
Common situations: Building an insert conditionally and skipping the values call in an edge case. Passing an optional request body field that is undefined. Refactoring that removes the values line but leaves the insert chain.
Related errors
- OUTPUT or RETURNING clause only supported by Microsoft SQL S
- indexPredicate option is not supported by the current databa
- onUpdate is not supported by the current database driver
- Function parameter isn't supported in the parameters. Please
- QueryBuilder parameter keys may only contain numbers, letter
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/efc387bc98eba533.
Report an issue: GitHub.