node-flyway
node-flyway copied to clipboard
flyway commands fail without explanation
Error: Unable to migrate {"url":"jdbc:postgresql://postgres:6678/mydb","user":"myuser","password":"xxx","defaultSchema":"public","migrationLocations":["src/flyway/migrations"]} {"errorCode":"UNABLE_TO_PARSE_RESPONSE","message":"Command successful but unable to parse Flyway response."}
this is from a docker container the command was not successful as I checked in the db other commands like clean and baseline also fail
I noticed this as well, for example when running info, the actual JSON response from the flyway cli does not have a warnings entry, but it looks like there's an assumption in the toFlywayResponse that it must exist, so transformArray throws because of if (!Array.isArray(val)) return invalidValue("array", val);.
Just as a quick debug, I tried disabling this line: https://github.com/domdinnes/node-flyway/blob/master/src/response/json-to-response.ts#L296
And the info command started working. (For other commands, and/or other data / migrations, there might be a slightly different exact reason why it's failing.)
Just a thought, maybe the typeMapProperties mapping just needs to track which properties/types are optional and then handle that throughout the transform functions?
Hei!
I am getting the same error, except with success: false .. so stuck not knowing where/why it has failed!
Note: I have verified that the connection to the db is working fine, and i am able to execute SQL commands directly on the db.
Response from flyway.migrate(...)
Migration response {
| success: false,
| error: {
| errorCode: 'UNABLE_TO_PARSE_RESPONSE',
| message: 'Command successful but unable to parse Flyway response.'
| },
| additionalDetails: {
| executionTime: 21261,
| flywayCli: {
| location: '/root/.node-flyway/flyway-9.22.3',
| source: 'DOWNLOAD',
| version: 'V9.22.3',
| hash: 'dded1ea374bc7311a61a725e6597e081'
| }
| }
| }
| {
| errorCode: 'UNABLE_TO_PARSE_RESPONSE',
| message: 'Command successful but unable to parse Flyway response.'
| }
| /bff/server.ts:116
| throw new Error("Unable to migrate db");
I am on node v22.
Dockerfile.dev
FROM --platform=linux/amd64 node:22-alpine
RUN apk update && apk add bash
WORKDIR /bff
COPY package.json yarn.lock tsconfig.json /bff/
RUN yarn install
COPY server.ts /bff/
COPY . .
ENV PORT 3005
CMD [ "yarn", "dev"]
And my package.json looks like this --
"scripts": {
"dev": "node --env-file-if-exists=.env.local --experimental-transform-types server.ts",
"start": "node --env-file-if-exists=.env --experimental-transform-types server.ts"
},
"dependencies": {
"axios": "^1.7.9",
"body-parser": "^1.20.3",
"cookie-parser": "^1.4.7",
"cors": "^2.8.5",
"date-fns": "^4.1.0",
"express": "^4.21.2",
"fast-csv": "^5.0.2",
"minimatch": "^10.0.1",
"node-flyway": "^0.0.12",
"pg": "^8.13.1"
},
Can someone help, please? thanks a tonne in advance!
@dhvector - thanks for taking some time to look into this. I'll see if I can reproduce and get a fix raised.
I think the problem is that this code literally can not parse the json response from flyway. My guess is that Flyway has changed the json it returns in some Flyway versions and code can not parse it.