{"record":{"id":"2a2f7f9d7e75226a","repo":"ToolJet/ToolJet","slug":"duplicate-column-keys-are-not-allowed","errorCode":null,"errorMessage":"Duplicate column keys are not allowed","messagePattern":"Duplicate column keys are not allowed","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"marketplace/plugins/supabase/lib/index.ts","lineNumber":128,"sourceCode":"    const { create_table_name, create_body } = queryOptions;\n    if (!create_body) throw new Error('Body required to create rows in table');\n    const res = await supabaseClient.from(create_table_name).insert(JSON.parse(create_body));\n    return res;\n  }\n\n  async updateRows(queryOptions: QueryOptions, supabaseClient: SupabaseClientType): Promise<Response> {\n    const { update_table_name, update_filters, update_column_fields } = queryOptions;\n    if (!update_column_fields) throw new Error('No column(s) provided to update');\n\n    const updateColumnValues: Column[] = Object.values(update_column_fields);\n    if (!updateColumnValues.length) throw new Error('No column(s) provided to update');\n\n    const columnNames: string[] = updateColumnValues.map((item) => item.column).filter((columnName) => !!columnName);\n    if (!columnNames.length) throw new Error('Provide column(s) with valid data');\n\n    const isDuplicate: boolean = columnNames.some((item, idx) => columnNames.indexOf(item) != idx);\n    if (isDuplicate) {\n      throw new Error('Duplicate column keys are not allowed');\n    }\n    const updateQuery = supabaseClient.from(update_table_name).select();\n    if (update_filters) {\n      const updateFiltersData: Filter[] = Object.values(update_filters);\n      this.addQueryFilters(updateQuery, updateFiltersData);\n    }\n    const { data, error } = await updateQuery;\n    if (error) throw new Error('Failed to fetch table rows to update');\n\n    const columnsData: object = {};\n    updateColumnValues.forEach((columnObj) => {\n      columnsData[columnObj.column] = columnObj.value;\n    });\n    const updateQueryRes: object[] = data.map((data: object) => ({ ...data, ...columnsData }));\n    const res = await supabaseClient.from(update_table_name).upsert(updateQueryRes).select();\n    return res;\n  }\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/ToolJet/ToolJet/blob/20602a8e101f2e59686c9afde0d1402aac2c8871/marketplace/plugins/supabase/lib/index.ts#L110-L146","documentation":"Thrown by Supabase plugin updateRows() when two column-field entries target the same column name. The duplicate check `columnNames.some((item, idx) => columnNames.indexOf(item) != idx)` detects any repeated name and throws 'Duplicate column keys are not allowed' before building the update payload, because the later value would silently overwrite the earlier one.","triggerScenarios":"update_column_fields contains two or more entries whose .column is identical, e.g. { c1: { column: 'status', value: 'a' }, c2: { column: 'status', value: 'b' } }.","commonSituations":"User added the same column twice by mistake; a duplicated control binding produced repeated column names; copy-paste of a column row without changing its target.","solutions":["Remove or merge duplicate column-field entries so each column name appears exactly once.","Dedupe client-side, keeping the intended value, before calling run().","When generating entries programmatically, key the object by column name to prevent repeats."],"exampleFix":"// before\nupdate_column_fields: {\n  c1: { column: 'status', value: 'a' },\n  c2: { column: 'status', value: 'b' }\n}\n\n// after\nupdate_column_fields: { c1: { column: 'status', value: 'b' } }","handlingStrategy":"validation","validationCode":"function ensureNoDuplicateColumns(qo) {\n  if (qo.operation !== 'update_row') return;\n  const names = Object.values(qo.update_column_fields || {}).map(c => c && c.column).filter(Boolean);\n  const dupe = names.find((n, i) => names.indexOf(n) !== i);\n  if (dupe) throw new Error(`Duplicate column keys are not allowed: ${dupe}`);\n}\nensureNoDuplicateColumns(queryOptions);","typeGuard":"function columnNamesUnique(qo): boolean {\n  if (qo.operation !== 'update_row') return true;\n  const names = Object.values(qo.update_column_fields || {}).map(c => c && c.column).filter(Boolean);\n  return names.every((n, i) => names.indexOf(n) === i);\n}","tryCatchPattern":"try { await svc.run(src, qo, id); } catch (e) { if (/Duplicate column/.test(e.message)) { dedupeColumnFields(); return; } throw e; }","preventionTips":["Key the update_column_fields object by column name so duplicates are impossible by construction.","Run a uniqueness check on column names in the UI and block Run on conflict.","When merging column rows programmatically, last-write-wins to a single entry per column."],"tags":["supabase","validation","user-input","update","duplicate","plugin"],"backgroundTag":null,"analyzedSha":"20602a8e101f2e59686c9afde0d1402aac2c8871","analyzedAt":"2026-08-13T05:58:54.221Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}