Immutable solution version
Read Platform.sh service credentials via config.credentials(), guarded by hasRelationship()
Complete solution
Do not hand-decode `PLATFORM_RELATIONSHIPS` yourself: it is base64-encoded JSON, and every language's Platform.sh config reader gives you `credentials('database')` returning the parsed object (user, password, host, dbname) ready to pass to your DB client.
Do not hand-decode PLATFORM_RELATIONSHIPS yourself: it is base64-encoded JSON, and every language's Platform.sh config reader gives you credentials('database') returning the parsed object (user, password, host, dbname) ready to pass to your DB client. Guard the call with hasRelationship('database') first: environments without that relationship defined throw instead of returning empty credentials, and the guard turns a deploy crash into a clean skip. The relationship name in code must match the key in your .platform.app.yaml relationships block, not the service name in services.yaml: those are two different names and mixing them is the classic connection failure.
Context: Web source (platformsh-config package docs on skypack.dev): Platform.sh services are defined in services.yaml and exposed to the app via a relationship in .platform.app.yaml. Credentials arrive in the PLATFORM_RELATIONSHIPS environment variable as base64-encoded JSON. Instead of decoding it yourself, use the config reader: config.credentials('database') returns the object (user, password, host, dbname), and config.hasRelationship('database') guards the access so a missing relationship does not throw.
Evidence
Source: Web source (platformsh-config package docs on skypack.dev): Platform.sh services are defined in services.yaml and exposed to the app via a relationship in .platform.app.yaml. Credentials arrive in the PLATFORM_RELATIONSHIPS environment variable as base64-encoded JSON. Instead of decoding it yourself, use the config reader: config.credentials('database') returns the object (user, password, host, dbname), and config.hasRelationship('database') guards the access so a missing relationship does not throw.
Verified resolution: Do not hand-decode PLATFORM_RELATIONSHIPS yourself: it is base64-encoded JSON, and every language's Platform.sh config reader gives you credentials('database') returning the parsed object (user, password, host, dbname) ready to pass to your DB client. Guard the call with hasRelationship('database') first: environments without that relationship defined throw instead of returning empty credentials, and the guard turns a deploy crash into a clean skip. The relationship name in code must match the key in your .platform.app.yaml relationships block, not the service name in services.yaml: those are two different names and mixing them is the classic connection failure.
Source URL: https://www.skypack.dev/view/platformsh-config
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_yCZhe_905ZofEWwVbss3zQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Read Platform.sh service credentials via config.credentials(), guarded by hasRelationship() <span>— Vectle</span></a>