[🐛] builderbot@latest - Error al recibir un mensaje nuevo e intentar guardar el contact con Postgresql
rodrimarchese opened this issue · comments
¿Que versión estas usando?
v2
¿Sobre que afecta?
Base de datos
Describe tu problema
Pasos que hice:
1-Cree nuevo proyecto utilizando pnpm create builderbot@latest
[baileys, postgres, typescript]
2-Introduje mi .env con mis credenciales de mi DB de Postgres (NO toque nada del codigo que viene por defecto)
3-Conecte mi wpp
4-Recibi un "Hola"
5-Error a continuacion:
Error registering history entry: error: null value in column "phone" of relation "contact" violates not-null constraint
at /Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/pg@8.11.4/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async e.save (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+database-postgres@1.1.0/node_modules/@builderbot/database-postgres/dist/index.cjs:1:856)
at async CoreClass.sendProviderAndSave (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:14350:17)
at async Object.promiseInFunc (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:14052:25)
at async Queue.processItem (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:726:27)
at async Promise.all (index 0)
at async Queue.processQueue (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:807:13) {
length: 499,
severity: 'ERROR',
code: '23502',
detail: 'Failing row contains (2, null, 2024-04-02 17:59:50.5162, null, null, null).',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: 'SQL statement "INSERT INTO contact (phone)\n' +
' VALUES (in_phone)\n' +
' RETURNING id"\n' +
'PL/pgSQL function save_or_update_history_and_contact(character varying,character varying,text,text,character varying,jsonb) line 8 at SQL statement',
schema: 'public',
table: 'contact',
column: 'phone',
dataType: undefined,
constraint: undefined,
file: 'execMain.c',
line: '1968',
routine: 'ExecConstraints'
}
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
error: null value in column "phone" of relation "contact" violates not-null constraint
at /Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/pg@8.11.4/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async e.save (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+database-postgres@1.1.0/node_modules/@builderbot/database-postgres/dist/index.cjs:1:856)
at async CoreClass.sendProviderAndSave (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:14350:17)
at async Object.promiseInFunc (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:14052:25)
at async Queue.processItem (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:726:27)
at async Promise.all (index 0)
at async Queue.processQueue (/Users/rodrimarchese/LTMsoluciones/base-ts-baileys-postgres/node_modules/.pnpm/@builderbot+bot@1.1.0/node_modules/@builderbot/bot/dist/index.cjs:807:13) {
length: 499,
severity: 'ERROR',
code: '23502',
detail: 'Failing row contains (2, null, 2024-04-02 17:59:50.5162, null, null, null).',
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: 'SQL statement "INSERT INTO contact (phone)\n' +
' VALUES (in_phone)\n' +
' RETURNING id"\n' +
'PL/pgSQL function save_or_update_history_and_contact(character varying,character varying,text,text,character varying,jsonb) line 8 at SQL statement',
schema: 'public',
table: 'contact',
column: 'phone',
dataType: undefined,
constraint: undefined,
file: 'execMain.c',
line: '1968',
routine: 'ExecConstraints'
}
Node.js v21.7.1
Failed running './src/app.ts'
Asumo que el problema viene de que por alguna razon "phone" me queda en null, ya sea por un tiempo (o no), y que la db no lo acepta.
Reproducir error
No response
Información Adicional
No response
@Elimeleth can you check it?
@Elimeleth can you check it?
Obiously beibi
![]()
Me gustaria ayudar, pero quizas este NOT NULL esta por algo, no se si la solucion sera sacarlo u otra cosa.
Al crearse por primera vez se dispara una funcion plpsql la cual crea un history mockup, espera un phone el cual no esta representado aún en la interfaz, se anexa el from el cual ya es conocido
@Elimeleth perdona, algo entendi, pero no me quedo claro si fue una sugerencia para un fix. Si necesitas estoy dispuesto a ayudarte a fixearlo, pero deberias decirme que es lo que hay que cambiar
@Elimeleth perdona, algo entendi, pero no me quedo claro si fue una sugerencia para un fix. Si necesitas estoy dispuesto a ayudarte a fixearlo, pero deberias decirme que es lo que hay que cambiar
ya esta hecho :)
@Elimeleth perdona, algo entendi, pero no me quedo claro si fue una sugerencia para un fix. Si necesitas estoy dispuesto a ayudarte a fixearlo, pero deberias decirme que es lo que hay que cambiar
ya esta hecho :)
No lo habia visto. Muchas gracias!!
Se cambio la metodologia de enfoque y solo se acoplo el fix al sql ejecutado por la funcion plpsql