hasura / hasura/graphql-engine

server: edge case bug in /healthz/sources API endpoint

Open
#9,904 0 comments 0 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information
Server Version: 2.33.4-cloud.1

### Environment
Cloud

### What is the current behaviour?

When calling `healthz/sources` [endpoint](https://hasura.io/docs/latest/api-reference/source-health/#api-spec), it returns following error

```
"error": "environment variable 'PG_DATABASE_URL' not set",
"status": "FAILED",
```

This happens even though user has set `PG_DATABASE_URL` in their env vars under cloud project settings.

### What is the expected behaviour?

It should not throw the above error if `PG_DATABASE_URL` is set in env vars regardless of eventual outcome of API response( being `success` or `failure`).

### How to reproduce the issue?

1. Connect Hasura with database where Database URL is set [via env vars inside Hasura cloud project settings](https://hasura.io/docs/latest/databases/database-config/index/#connect-to-an-existing-database)
2. After successful connection, you can try checking health of your database by hitting `healthz/sources` endpoint. Ref - https://hasura.io/docs/latest/api-reference/source-health/#api-spec
3. Check the response of the API where it should have similar error as mentioned above

### Screenshots or Screencast

postman_API_example

### Keywords

healthz database

Contributor guide

Open the contributing guide

Research direction

Start at the healthz/sources API endpoint and trace how PG_DATABASE_URL configured in Hasura Cloud project settings is resolved during the health check. Reproduce the request against a connected database, then verify that the response no longer reports the variable as unset, regardless of whether the health check succeeds or fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.