SigNoz/signoz · error
CodeInternal
CodeInternal
Error message
unable to fetch routing policy with ID: %s
What it means
Thrown by the SQL routing-policy store when a Bun ORM NewSelect on route_policies fails for a reason other than 'no rows' (that case is mapped to CodeNotFound). It wraps the underlying database error with CodeInternal, meaning the query itself broke: connection issues, context cancellation, or schema/model mismatch.
Source
Thrown at pkg/alertmanager/nfmanager/nfroutingstore/sqlroutingstore/store.go:29
type store struct {
sqlstore sqlstore.SQLStore
}
func NewStore(sqlstore sqlstore.SQLStore) routeTypes.RouteStore {
return &store{
sqlstore: sqlstore,
}
}
func (store *store) GetByID(ctx context.Context, orgId string, id string) (*routeTypes.RoutePolicy, error) {
route := new(routeTypes.RoutePolicy)
err := store.sqlstore.BunDBCtx(ctx).NewSelect().Model(route).Where("id = ?", id).Where("org_id = ?", orgId).Scan(ctx)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, store.sqlstore.WrapNotFoundErrf(err, errors.CodeNotFound, "routing policy with ID: %s does not exist", id)
}
return nil, errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "unable to fetch routing policy with ID: %s", id)
}
return route, nil
}
func (store *store) Create(ctx context.Context, route *routeTypes.RoutePolicy) error {
_, err := store.sqlstore.BunDBCtx(ctx).NewInsert().Model(route).Exec(ctx)
if err != nil {
return errors.NewInternalf(errors.CodeInternal, "error creating routing policy with ID: %s", route.ID)
}
return nil
}
func (store *store) CreateBatch(ctx context.Context, route []*routeTypes.RoutePolicy) error {
_, err := store.sqlstore.BunDBCtx(ctx).NewInsert().Model(&route).Exec(ctx)
if err != nil {
return errors.NewInternalf(errors.CodeInternal, "error creating routing policies: %v", err)View on GitHub (pinned to 5069bf80b0)
Solutions
- Check the wrapped underlying error (err) in logs — it names the real cause (connection refused, no such table, cancelled context)
- Verify the database is reachable and migrations for the routing policy table have been applied
- Confirm orgId and id are valid non-empty strings of the expected type/UUID format
- Retry once the transient DB issue (restart, failover, connection pool exhaustion) is resolved
Example fix
// before
route, err := store.GetByID(ctx, orgId, id)
if err != nil { return err }
// after
route, err := store.GetByID(ctx, orgId, id)
if err != nil {
if errors.Is(err, errors.CodeNotFound) { // handle missing policy
return fmt.Errorf("policy not found: %s", id)
}
return fmt.Errorf("internal db error fetching policy %s: %w", id, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
if id == "" || orgId == "" { return errors.New("id and orgId are required") } Type guard
func isNotFoundErr(err error) bool { return err != nil && strings.Contains(err.Error(), "does not exist") } Try / catch
route, err := store.GetByID(ctx, orgId, id)
if err != nil {
if isNotFoundErr(err) { /* 404 path */ }
return fmt.Errorf("fetch policy %s: %w", id, err)
} Prevention
- Keep DB migrations in sync with the app version
- Use request contexts with sensible timeouts
- Validate id/orgId format before querying
When it happens
Trigger: Calling GetByID(ctx, orgId, id) on the routing policy store while the database is unreachable, the query context is cancelled/timed out, or the route_policies table schema doesn't match the routeTypes.RoutePolicy model (e.g. after a migration that hasn't run).
Common situations: DB credentials or connectivity misconfigured in the SigNoz deployment; pending database migrations after an upgrade; the org_id column value passed doesn't match expected format causing a driver-level type error; context deadline exceeded under load.
Related errors
- internal
- CodeInvalidInput
- ErrCodeAlertmanagerStateNotFound
- couldn't create cloud integration service account: %w
- failed to update deploy status
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/a14fae0b92ab8f9a.
Report an issue: GitHub.