Error: No service definition found for 'postgres'
See original GitHub issueHi,
recently I am getting below error when running npx cds-pg deploy app --to postgres
:
node ➜ /workspaces/cap-ratings $ npm run deploy
> cap-ratings@0.1.0 deploy
> npx cds-pg deploy app --to postgres
[cds.connect] - No service definition found for 'postgres', as required by 'cds.requires.postgres': {
impl: 'cds-pg',
model: [ 'app' ],
credentials: {
host: 'postgres-svc',
port: '5432',
user: 'slonik',
password: 'topsekret',
database: 'cap-ratings',
schema: 'public'
}
}
(node:19603) UnhandledPromiseRejectionWarning: Error: No service definition found for 'postgres'
at AsyncFunction.connect.to (/workspaces/cap-ratings/node_modules/@sap/cds/lib/connect/index.js:42:11)
at async Object.to (/workspaces/cap-ratings/node_modules/@sap/cds/lib/deploy.js:21:23)
at async deploy (/workspaces/cap-ratings/node_modules/cds-pg/bin/cds-pg.js:11:3)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:19603) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:19603) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
node ➜ /workspaces/cap-ratings $
Project setup look as follows:
cds
node ➜ /workspaces/cap-ratings $ cds -v
@sap/cds: 5.5.4
@sap/cds-compiler: 2.7.0
@sap/cds-dk: 4.5.3
@sap/cds-foss: 3.0.0
@sap/cds-odata-v2-adapter-proxy: 1.7.12
@sap/eslint-plugin-cds: 2.1.1
Node.js: v14.17.6
cap-ratings: 0.1.0
home: /workspaces/cap-ratings/node_modules/@sap/cds
.cdsrc.json
{
"features": {
"fiori_preview": true
},
"requires": {
"db": {
"kind": "postgres"
},
"postgres": {
"impl": "cds-pg",
"model": [
"app"
]
}
}
}
default-env.json
{
"PORT": 5005,
"VCAP_SERVICES": {
"postgres": [
{
"name": "postgres",
"label": "postgres",
"tags": [
"postgres"
],
"credentials": {
"host": "postgres-svc",
"port": "5432",
"user": "slonik",
"password": "topsekret",
"database": "cap-ratings",
"schema": "public"
}
}
]
},
"DEBUG": "ratings-service"
}
package.json
{
"name": "cap-ratings",
"version": "0.1.0",
"description": "A simple CAP project.",
"private": true,
"dependencies": {
"@sap/cds": "^5.5.4",
"@sap/cds-odata-v2-adapter-proxy": "^1.7.12",
"cds-pg": "^0.1.13",
"express": "^4.17.1",
"helmet": "^4.6.0",
"passport": "^0.5.0"
},
"devDependencies": {
"@sap/eslint-plugin-cds": "^2.1.1",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"sqlite3": "^5.0.2"
},
"scripts": {
"deploy": "npx cds-pg deploy app --to postgres",
"watch": "cds watch",
"mock": "cds run --with-mocks --in-memory",
"prestart": "npm run deploy",
"start": "npx cds run",
"build": "cds build",
"predocker": "npm run build",
"docker": "docker build -t pwasem/cap-ratings:latest ."
}
}
Maybe an issue with recent @sap/cds-dk
or sap/cds
versions?
Thank you in advance for having a look!
Best regards,
Pascal
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
PostgreSQL definition of service not found (pgAdmin, psql, ...)
Issue. Whenever I try to create a new server from pgAdmin III by setting 'service_name' under the option 'Service', I encounter this error...
Read more >HANA Express 2.0 SP04 - Building HDI: Error No Service ...
it's saying that no service definition was found. Check that your yaml file contains all your services: db and srv services, all must...
Read more >"Failed to logon to Database Server definition of service ...
This issue may occur if your PostgreSQL pg_service.conf file doesn't contain the database information provided in the connection details or ...
Read more >For Control-M/Server, when I run the command "psql", why do ...
For Control-M/Server, when I run the command "psql", why do I receive the error "PG::ConnectionBad definition of service XXXXX not found"?
Read more >Documentation: 9.0: PostgreSQL Error Codes
Error Code Meaning Condition Name
00000 SUCCESSFUL COMPLETION successful_completion
01000 WARNING warning
0100C DYNAMIC RESULT SETS RETURNED dynamic_result_sets_returned
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @pwasem,
change your .cdsrc.json to add the dialect to the postgres section:
And change your default-env.json to the tags “plain” and “db”:
That should do the trick.
Cheers, Sebastian
@sebastianesch
How should the actual
default-env.json
look in this case?Thx!