fix(go): redact internal handler errors (#15746)

### What problem does this PR solve?

Refs #15743

Some Go API handlers return raw `err.Error()` strings in
`CodeServerError` responses. Those errors can include internal backend
details such as database, storage, search engine, or host information.

This PR adds a small shared `jsonInternalError` helper for handler-level
internal failures. The helper logs the raw error server-side with
request method/path context, then returns the existing generic
`common.CodeServerError.Message()` to API clients.

This first slice migrates the existing `jsonError(c,
common.CodeServerError, err.Error())` production call sites in agent,
dataset graph, file, and system handlers. It intentionally does not
close the full issue because direct `c.JSON` error responses in other
handlers remain for follow-up PRs.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):

### Tests

- `/root/go/bin/go test ./internal/handler -count=1`

---------

Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com>
This commit is contained in:
bitloi
2026-06-12 05:09:10 -03:00
committed by GitHub
parent e96bc37d06
commit 22a058f56c
7 changed files with 86 additions and 19 deletions

View File

@@ -125,7 +125,7 @@ func (h *SystemHandler) GetStatus(c *gin.Context) {
status, err := h.systemService.GetStatus()
if err != nil {
jsonError(c, common.CodeServerError, err.Error())
jsonInternalError(c, err)
return
}