Validate API key and model availability at connection time
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- go, postgresql
- Domain
- api, authentication, backend
Research direction
Read auth.go:17-139 to understand authentication and startup messaging, then inspect connection.go around lines 113-117 where the LLM client is created before the query loop. Trace the LLMClient implementations for OpenAI and Anthropic and determine how validation and PostgreSQL FATAL errors should be handled. Done means connections reject invalid keys or unavailable models before queries, with the documented error codes.
Written by the indexing model from the issue text.
Description
Problem
The authenticate function (auth.go:17-90) performs the PostgreSQL password
handshake - receives the StartupMessage, requests the cleartext password, and
returns the extracted credentials (provider, API key, model, options). It does
no validation.
Separately, sendStartupMessages (auth.go:93-139) sends AuthenticationOk and
startup parameters to the client - also with no validation.
Between these two calls and the query loop, nothing verifies that the API key
is valid or the model exists. The user only finds out on their first query
when the LLM API call fails.
Proposed solution
Add a Validate(ctx) error method to the LLMClient interface. Call it in
connection.go after creating the LLM client (line ~113) and before entering
the query loop (line ~117).
Each provider implements validation differently:
- OpenAI:
GET /v1/modelsor a minimal completion call - Anthropic: minimal message call or equivalent
On failure, send a PostgreSQL FATAL error and close the connection:
- Invalid API key →
FATAL 28P01 (invalid_password) - Invalid/unavailable model →
FATAL 3D000 (invalid_catalog_name)
Considerations
- Adds latency to every new connection - should use the cheapest possible API call
- Could be opt-out via a flag (
-skip-validation) for local/trusted setups
- Dominant language
- Go
- Stars
- 40
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/prow#953 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
caddyserver/caddy#8046 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
L1 recommended for recruits
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·