{"record":{"id":"6b4a2398ec82704c","repo":"Billionmail/BillionMail","slug":"failed-to-get-all-domains-w","errorCode":null,"errorMessage":"failed to get all domains: %w","messagePattern":"failed to get all domains: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/controller/domains/domains_v1_get_domain_all.go","lineNumber":21,"sourceCode":"import (\n\t\"billionmail-core/internal/service/domains\"\n\t\"billionmail-core/internal/service/public\"\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/gogf/gf/v2/errors/gcode\"\n\t\"github.com/gogf/gf/v2/errors/gerror\"\n\n\t\"billionmail-core/api/domains/v1\"\n)\n\nfunc (c *ControllerV1) GetDomainAll(ctx context.Context, req *v1.GetDomainAllReq) (res *v1.GetDomainAllRes, err error) {\n\tres = &v1.GetDomainAllRes{}\n\n\tres.Data, err = domains.All(ctx)\n\n\tif err != nil {\n\t\tres.SetError(fmt.Errorf(\"failed to get all domains: %w\", gerror.NewCode(gcode.CodeInternalError, err.Error())))\n\t\treturn\n\t}\n\n\tres.SetSuccess(public.LangCtx(ctx, \"Success\"))\n\treturn\n}\n","sourceCodeStart":3,"sourceCodeEnd":28,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/controller/domains/domains_v1_get_domain_all.go#L3-L28","documentation":"GetDomainAll wraps an error from domains.All(ctx) into a gerror with gcode.CodeInternalError and sets it on the response via SetError. It signals the database-backed query that enumerates all domains failed; the SQL/database error text is embedded in the message.","triggerScenarios":"domains.All(ctx) returns an error — typically a PostgreSQL failure: DB unreachable, connection pool exhausted, 'domains' table missing (migration not run), or a query timeout.","commonSituations":"Postgres container down or restarting during deploy; wrong DB credentials in config; schema migrations not applied after an upgrade; network partition between app and DB in Docker Compose.","solutions":["Read the wrapped message for the underlying DB error (connection refused vs SQL syntax vs relation does not exist).","Verify PostgreSQL is up and reachable: check docker compose ps and connection settings in the config.","Run pending migrations so the 'domains' table exists.","Test credentials with psql; if pool exhaustion, raise pool limits or check for leaked connections."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// health-check DB before calling\nif err := gdb.Config().Master.Ping(); err != nil {\n\treturn fmt.Errorf(\"database unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, err := client.GetDomainAll(ctx, req)\nif err != nil {\n\tvar gerr *gerror.Error\n\tif errors.As(err, &gerr) && gerr.Code() == gcode.CodeInternalError {\n\t\treturn backoff.Retry(func() error {\n\t\t\t_, err = client.GetDomainAll(ctx, req)\n\t\t\treturn err\n\t\t}, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3))\n\t}\n\treturn err\n}","preventionTips":["Monitor PostgreSQL health and alerts","Run migrations on every deploy","Validate DB credentials in config before startup","Set sane pool limits and query timeouts"],"tags":["database","postgresql","domains"],"backgroundTag":"database-query-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}