Severity: π‘ MEDIUM β robustness gap
After goca init + feature + integrate, the server starts in "degraded mode" when no database is reachable (db = nil, by design, so health checks work). However, the generated repositories dereference the nil *gorm.DB on the first real request, causing a panic (recovered by net/http, so the connection is reset / client sees an empty reply).
Reproduction
goca init shop --module github.com/test/shop --database postgres
cd shop
goca feature User --fields "name:string,email:string"
goca integrate --all
go run ./cmd/server # no DB available
curl -i http://localhost:8080/api/v1/users # connection reset; server log: "http: panic serving ... nil pointer dereference"
Expected
With routes now correctly wired (#PR-52), endpoints are reachable, but a missing database should not panic. Options:
- The generated repository methods should guard
if r.db == nil { return ErrNoDatabase }, or
- The handler/usecase should translate a nil-DB / repository error into an HTTP 503, or
- The DI container / handlers should not be wired when
db == nil and the routes should return 503.
Notes
This is independent of the routing fix in PR #52 (which fixed the 404). It only manifests when running without a configured database; with a real DB the endpoints work.
Severity: π‘ MEDIUM β robustness gap
After
goca init+feature+integrate, the server starts in "degraded mode" when no database is reachable (db = nil, by design, so health checks work). However, the generated repositories dereference the nil*gorm.DBon the first real request, causing a panic (recovered bynet/http, so the connection is reset / client sees an empty reply).Reproduction
Expected
With routes now correctly wired (#PR-52), endpoints are reachable, but a missing database should not panic. Options:
if r.db == nil { return ErrNoDatabase }, ordb == niland the routes should return 503.Notes
This is independent of the routing fix in PR #52 (which fixed the 404). It only manifests when running without a configured database; with a real DB the endpoints work.