{"record":{"id":"d49409a43d1cf425","repo":"SigNoz/signoz","slug":"s","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"error_code","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"ee/sqlstore/postgressqlstore/provider.go","lineNumber":109,"sourceCode":"func (provider *provider) Dialect() sqlstore.SQLDialect {\n\treturn provider.dialect\n}\n\nfunc (provider *provider) Formatter() sqlstore.SQLFormatter {\n\treturn provider.formatter\n}\n\nfunc (provider *provider) BunDBCtx(ctx context.Context) bun.IDB {\n\treturn provider.bundb.BunDBCtx(ctx)\n}\n\nfunc (provider *provider) RunInTxCtx(ctx context.Context, opts *sql.TxOptions, cb func(ctx context.Context) error) error {\n\treturn provider.bundb.RunInTxCtx(ctx, opts, cb)\n}\n\nfunc (provider *provider) WrapNotFoundErrf(err error, code errors.Code, format string, args ...any) error {\n\tif err == sql.ErrNoRows {\n\t\treturn errors.Wrapf(err, errors.TypeNotFound, code, format, args...)\n\t}\n\n\treturn err\n}\n\nfunc (provider *provider) WrapAlreadyExistsErrf(err error, code errors.Code, format string, args ...any) error {\n\tvar pgErr *pgconn.PgError\n\tif errors.As(err, &pgErr) && (pgErr.Code == \"23505\" || pgErr.Code == \"23503\") {\n\t\treturn errors.Wrapf(err, errors.TypeAlreadyExists, code, format, args...)\n\t}\n\n\treturn err\n}\n\nfunc (dialect *dialect) ToggleForeignKeyConstraint(ctx context.Context, bun *bun.DB, enable bool) error {\n\treturn nil\n}\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/ee/sqlstore/postgressqlstore/provider.go#L91-L127","documentation":"WrapNotFoundErrf in the postgres sqlstore provider rewrites sql.ErrNoRows into a typed error with errors.TypeNotFound and the caller-supplied code/format — this '%s' format string is the caller's message applied to the no-rows error.","triggerScenarios":"Any repository read (Get/First by unique key) that returns sql.ErrNoRows while using provider.WrapNotFoundErrf, e.g. fetching a license/org/API-key by ID that does not exist.","commonSituations":"API 404s for missing entities; deleted rows still referenced; querying with the wrong org context or a stale ID from a previous deployment.","solutions":["Handle the returned NotFound error as an HTTP 404 rather than 500 in the caller layer","Verify the entity ID exists (and org scoping) before the read","Seed/re-create missing required rows if the entity should exist","Check for accidental table truncation or wrong database/database selection"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := store.WrapNotFoundErrf(dbErr, code, \"license %s not found\", id)\nif errors.Ast(err, errors.TypeNotFound) { return http.StatusNotFound }","preventionTips":["Map TypeNotFound to 404 in the HTTP layer","Verify entity IDs and org scoping before reads"],"tags":["signoz","sqlstore","not-found","postgres","go"],"backgroundTag":"record-not-found","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}