Validate API key and model availability at connection time
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- go, postgresql
- 领域
- api, authentication, backend
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Go
- 星标
- 40
- 派生
- 2
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
agent-butler-finding chore
难度 1/5 1 小时以内 新手友好度 88/100
jordansmall/spindrift#4146 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-3 小时 新手友好度 68/100
IBM/ibmcloud-volume-file-vpc#119 ·
-
security
难度 2/5 1-3 小时 新手友好度 66/100
IBM/networking-go-sdk#339 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
kubernetes-sigs/mcp-lifecycle-operator#439 ·
维护者通常 1 天内回复
-
area: global bug dx priority: low
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复