Files
cc-backend/85/8b34ef56b8/0/prompt.txt
Jan Eitzinger 9fff22afce Checkpoint: 858b34ef56b8
Entire-Session: 7916ffa0-cf9e-4cb7-a75f-8a1db33c75bd
Entire-Strategy: manual-commit
Entire-Agent: Claude Code
Ephemeral-branch: entire/7f3eb44-e3b0c4
2026-03-16 20:03:32 +01:00

64 lines
2.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Implement the following plan:
# Plan: Improve scanJob logging
## Context
`scanJob` in `internal/repository/job.go` (line 162) logs a `Warn` for every scan error, including the very common `sql.ErrNoRows` case. This produces noisy, unhelpful log lines like:
```
WARN Error while scanning rows (Job): sql: no rows in result set
```
Two problems:
1. `sql.ErrNoRows` is a normal, expected condition (callers are documented to check for it). It should not produce a warning.
2. When a real scan error does occur, there's no call-site context — you can't tell which of the ~10 callers triggered it.
The codebase already has a precedent for using `runtime.Caller(1)` in `internal/api/rest.go:188` to include file/line in log messages.
## Approach
Modify `scanJob` in `internal/repository/job.go`:
1. **Skip logging for `sql.ErrNoRows`** — return the error silently. All callers already handle this case themselves.
2. **Add caller context** for real scan errors using `runtime.Caller(1)` — include `file:line` in the warning message.
```go
import (
"database/sql"
"path/filepath"
"runtime"
// existing imports ...
)
func scanJob(row interface{ Scan(...any) error }) (*schema.Job, error) {
job := &schema.Job{}
if err := row.Scan(...); err != nil {
if err != sql.ErrNoRows {
_, file, line, _ := runtime.Caller(1)
cclog.Warnf("Error while scanning rows (Job) (%s:%d): %v", filepath.Base(file), line, err)
}
return nil, err
}
// ... rest unchanged
}
```
## Critical File
- `internal/repository/job.go` — only file to change (lines 154184)
## Imports to check
`database/sql` is likely already imported (used elsewhere in the package). `runtime` and `path/filepath` — check if already present; add if not.
## Verification
1. `go build ./...` — must compile cleanly
2. `go test ./internal/repository/...` — existing tests must pass
3. Manually: trigger a lookup for a non-existent job ID; confirm no warning is logged
4. Manually (or via test): force a real scan error; confirm warning includes `job.go:<line>`
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/jan/.claude/projects/-Users-jan-prg-CC-cc-backend/b03f52bf-e58e-45a2-8b95-af846938ee2c.jsonl