Skip to content

Auto-run health check after creating a connection #44

@zfarrell

Description

@zfarrell

After creating a connection, the CLI should automatically call the health check endpoint to validate credentials.

Currently, creating a connection only persists it (so it gets a stable ID for troubleshooting), which means invalid credentials aren't caught until the user manually calls the health check API. The CLI should layer the health check on top of that flow to give users immediate feedback.

Expected behavior:

  1. After a successful create connection, automatically call the health check endpoint.
  2. If the health check passes, report success as normal.
  3. If the health check fails, surface the error clearly and walk the user through updating the connection (e.g. prompt to fix credentials/config, re-create with corrected values), then re-run discover since it would have failed with the bad connection.

Relevant API calls:

  1. Create connectionPOST /v1/connections
{
  "name": "my-postgres",
  "source_type": "postgres",
  "config": { "host": "...", "port": 5432, "database": "..." },
  "secret_name": "my-pg-secret"       // or "secret_id": "secr_abc123"
}

Response (201):

{
  "id": "conn_abc123",
  "name": "my-postgres",
  "source_type": "postgres",
  "tables_discovered": 12,
  "discovery_status": "success",
  "discovery_error": null
}
  1. Health checkGET /v1/connections/{connection_id}/health
    Response (200):
{
  "connection_id": "conn_abc123",
  "healthy": true,
  "latency_ms": 42,
  "error": null
}

On failure, healthy is false and error contains the reason.

  1. Re-run discovery (after fixing credentials) — POST /v1/refresh
{
  "connection_id": "conn_abc123"
}

Note: there is (currently) no update-connection endpoint. If credentials are wrong, the user would need to update the underlying secret (via PUT /v1/secrets/{name}) or delete and re-create the connection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions