{"record":{"id":"39dab168c27e1ba5","repo":"n8n-io/n8n","slug":"invalid-prefix-option-given-for-this-entitymetad","errorCode":null,"errorMessage":"Invalid prefix option given for ${this.entityMetadata.targetName}#${this.propertyName}","messagePattern":"Invalid prefix option given for (.+?)#(.+?)","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/metadata/EmbeddedMetadata.ts","lineNumber":255,"sourceCode":"\t// ---------------------------------------------------------------------\n\n\tprotected buildPartialPrefix(): string[] {\n\t\t// if prefix option was not set or explicitly set to true - default prefix\n\t\tif (this.customPrefix === undefined || this.customPrefix === true) {\n\t\t\treturn [this.propertyName];\n\t\t}\n\n\t\t// if prefix option was set to empty string or explicity set to false - disable prefix\n\t\tif (this.customPrefix === '' || this.customPrefix === false) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// use custom prefix\n\t\tif (typeof this.customPrefix === 'string') {\n\t\t\treturn [this.customPrefix];\n\t\t}\n\n\t\tthrow new TypeORMError(\n\t\t\t`Invalid prefix option given for ${this.entityMetadata.targetName}#${this.propertyName}`,\n\t\t);\n\t}\n\n\tprotected buildPrefix(connection: DataSource): string {\n\t\tlet prefixes: string[] = [];\n\t\tif (this.parentEmbeddedMetadata)\n\t\t\tprefixes.push(this.parentEmbeddedMetadata.buildPrefix(connection));\n\n\t\tprefixes.push(...this.buildPartialPrefix());\n\n\t\treturn prefixes.join('_'); // todo: use naming strategy instead of \"_\"  !!!\n\t}\n\n\tprotected buildParentPropertyNames(): string[] {\n\t\treturn this.parentEmbeddedMetadata\n\t\t\t? this.parentEmbeddedMetadata.buildParentPropertyNames().concat(this.propertyName)\n\t\t\t: [this.propertyName];","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/metadata/EmbeddedMetadata.ts#L237-L273","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n@Embedded(() => Address, { prefix: 0 as any })\naddress!: Address;\n\n// after - valid prefix type\n@Embedded(() => Address, { prefix: 'addr_' })\naddress!: Address;\n// or disable prefixing\n@Embedded(() => Address, { prefix: false })\naddress!: Address;","handlingStrategy":"type-guard","validationCode":"function asEmbeddedPrefix(v: unknown): string | boolean | undefined {\n  if (v === undefined || typeof v === 'string' || typeof v === 'boolean') return v;\n  throw new Error(`Invalid @Embedded prefix option: expected string | boolean, got ${typeof v}`);\n}\n// apply only at decoration time (statically); for dynamic configs, validate before codegen\nconst prefix = asEmbeddedPrefix(config.userAddressPrefix);","typeGuard":"function isValidEmbeddedPrefix(v: unknown): v is string | boolean {\n  return typeof v === 'string' || typeof v === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["typeorm","embedded","decorators","metadata","api-misuse"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}