Failed to migrate db error: zero-length delimited identifier at or near """"
kpanter opened this issue · 5 comments
Describe the bug
Hi,
wanted to deploy unleash on kuberentes with external postgresql database.
My current deployment envs look like:
env:
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
name: unleash-postgresql
key: password
- name: DATABASE
value: unleash
- name: DATABASE_HOST
value: example.postgres.database.azure.com
- name: DATABASE_PASS
value: $(POSTGRESQL_PASSWORD)
- name: DATABASE_PORT
value: '5432'
- name: NODE_EXTRA_CA_CERTS
value: "/usr/local/share/ca.crt"
- name: DATABASE_USER
value: unleash_user
- name: DATABASE_URL
value: postgres://$(DATABASE_USER):$(DATABASE_PASS)@$(DATABASE_HOST):$(DATABASE_PORT)/$(DATABASE)
- name: DATABASE_SSL
value: "{ \"rejectUnauthorized\": false, \"ca\": \"$(cat /usr/local/share/ca.crt)\" }"
- name: UNLEASH_URL
value: "https://unleash.example.com"
- name: LOG_LEVEL
value: info
Envs replacement is working.
I run points mentioned here [(https://docs.getunleash.io/using-unleash/deploy/database-setup](https://docs.getunleash.io/using-unleash/deploy/database-setup
Also tested some ca cert variations but getting
[2023-11-07T09:47:23.129] [ERROR] server-impl.js - Failed to migrate db error: zero-length delimited identifier at or near """"
at Parser.parseErrorMessage (/unleash/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/unleash/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/unleash/node_modules/pg-protocol/dist/parser.js:39:38)
at TLSSocket. (/unleash/node_modules/pg-protocol/dist/index.js:11:42)
at TLSSocket.emit (node:events:514:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {
length: 111,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '30',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1192',
routine: 'scanner_yyerror'
}
Any idea where is the issue?
Steps to reproduce the bug
No response
Expected behavior
No response
Logs, error output, etc.
No response
Screenshots
No response
Additional context
No response
Unleash version
5.5.6
Subscription type
Open source
Hosting type
Self-hosted
SDK information (language and version)
No response
Looks like there is an issue with parsing one of environment variables. Did you try to run any parser/validator on your Kubernetes config?
PostgreSQL version is 15.2
Using Lens, it validates Kubernetes config
for eg if I change DATABASE_SSL env to
- name: DATABASE_SSL
value: "{ "rejectUnauthorized": false, "ca": "$(cat /usr/local/share/ca.crt)" }"
I get specific self-signed certificate error
[2023-11-07T11:07:23.345] [ERROR] server-impl.js - Failed to migrate db OperationalError: self-signed certificate in certificate chain
at TLSSocket.onConnectSecure (node:_tls_wrap:1550:34)
... 2 lines matching cause stack trace ...
at ssl.onhandshakedone (node:_tls_wrap:743:12) {
cause: Error: self-signed certificate in certificate chain
at TLSSocket.onConnectSecure (node:_tls_wrap:1550:34)
at TLSSocket.emit (node:events:514:28)
at TLSSocket._finishInit (node:_tls_wrap:967:8)
at ssl.onhandshakedone (node:_tls_wrap:743:12) {
code: 'SELF_SIGNED_CERT_IN_CHAIN'
},
isOperational: true,
code: 'SELF_SIGNED_CERT_IN_CHAIN'
Ok fixed seems that GRANT ALL PRIVILEGES ON DATABASE unleash to unleash_user; is not enough, had to use admin/owner credentials.
Thank you for sharing this. It turns out that since we started using sql functions "GRANT ALL" is not enough. We will expand our documentation next week