n8n-io/n8n · error · TypeORMError
Invalid prefix option given for ${this.entityMetadata.target
Error message
Invalid prefix option given for ${this.entityMetadata.targetName}#${this.propertyName} What it means
EmbeddedMetadata.buildPartialPrefix handles the @Embedded decorator's `prefix` option. After checking for false and '' (both disable prefix) and a plain string (custom prefix), any other type falls through to `throw new TypeORMError(Invalid prefix option given for ${targetName}#${propertyName})`. The decorator only accepts string | boolean | '' — anything else (number, object, null, array) is invalid.
Source
Thrown at packages/@n8n/typeorm/src/metadata/EmbeddedMetadata.ts:255
// ---------------------------------------------------------------------
protected buildPartialPrefix(): string[] {
// if prefix option was not set or explicitly set to true - default prefix
if (this.customPrefix === undefined || this.customPrefix === true) {
return [this.propertyName];
}
// if prefix option was set to empty string or explicity set to false - disable prefix
if (this.customPrefix === '' || this.customPrefix === false) {
return [];
}
// use custom prefix
if (typeof this.customPrefix === 'string') {
return [this.customPrefix];
}
throw new TypeORMError(
`Invalid prefix option given for ${this.entityMetadata.targetName}#${this.propertyName}`,
);
}
protected buildPrefix(connection: DataSource): string {
let prefixes: string[] = [];
if (this.parentEmbeddedMetadata)
prefixes.push(this.parentEmbeddedMetadata.buildPrefix(connection));
prefixes.push(...this.buildPartialPrefix());
return prefixes.join('_'); // todo: use naming strategy instead of "_" !!!
}
protected buildParentPropertyNames(): string[] {
return this.parentEmbeddedMetadata
? this.parentEmbeddedMetadata.buildParentPropertyNames().concat(this.propertyName)
: [this.propertyName];View on GitHub (pinned to 5ac6606e81)
Solutions
- Use a string prefix, false, or '' only: `@Embedded(() => Address, { prefix: 'addr_' })` or `{ prefix: false }`.
- Validate dynamic prefix values before applying the decorator (coerce to string or boolean).
- Type the prefix option strictly as `string | boolean` at the configuration boundary.
Example fix
// before
@Embedded(() => Address, { prefix: 0 as any })
address!: Address;
// after - valid prefix type
@Embedded(() => Address, { prefix: 'addr_' })
address!: Address;
// or disable prefixing
@Embedded(() => Address, { prefix: false })
address!: Address; Defensive patterns
Strategy: type-guard
Validate before calling
function asEmbeddedPrefix(v: unknown): string | boolean | undefined {
if (v === undefined || typeof v === 'string' || typeof v === 'boolean') return v;
throw new Error(`Invalid @Embedded prefix option: expected string | boolean, got ${typeof v}`);
}
// apply only at decoration time (statically); for dynamic configs, validate before codegen
const prefix = asEmbeddedPrefix(config.userAddressPrefix); Type guard
function isValidEmbeddedPrefix(v: unknown): v is string | boolean {
return typeof v === 'string' || typeof v === 'boolean';
} Prevention
- Restrict @Embedded prefix option to string, '', or false.
- Validate prefix values coming from config files before use.
- Type the option as `string | boolean` to prevent `any` slipping through.
- Add a unit test over a sample of prefix values to catch invalid types early.
When it happens
Trigger: Decorating `@Embedded(() => Address, { prefix: 0 })` or `{ prefix: null }` or `{ prefix: { custom: 'x' } }`; programmatically building embed metadata with a non-conforming prefix; reading prefix from a config file that yielded a non-string/non-boolean; copy-paste of an options object intended for a different decorator.
Common situations: Misunderstanding the prefix option's accepted types; dynamic config-driven embedding with unvalidated prefix values; refactor that changed prefix from string to object without updating all sites; TypeScript `any` letting invalid types through.
Related errors
- Column "${columnName}" was not found in table "${metadata.na
- Column ${propertyPath} was not found in ${metadata.targetNam
- Custom repository ${repository.name} was not found. Did you
- Custom entity repository ${repository.name} cannot inherit R
- Transaction method requires callback in second parameter if
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/39dab168c27e1ba5.
Report an issue: GitHub.