Fix: Event getter backwards compat (#2337)

* feat: query for getting event in v1

* feat: extend populator to fetch v1 event

* fix: rm debug

* fix: simplify join

* fix: ctx
This commit is contained in:
matt
2025-09-24 17:10:20 -04:00
committed by GitHub
parent 54a5e50de1
commit ee17433ac9
4 changed files with 55 additions and 1 deletions
+19 -1
View File
@@ -9,6 +9,8 @@ import (
"time"
"github.com/getkin/kin-openapi/openapi3"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/rs/zerolog"
@@ -43,6 +45,7 @@ import (
"github.com/hatchet-dev/hatchet/api/v1/server/middleware/ratelimit"
"github.com/hatchet-dev/hatchet/api/v1/server/oas/gen"
"github.com/hatchet-dev/hatchet/pkg/config/server"
"github.com/hatchet-dev/hatchet/pkg/repository/postgres/dbsqlc"
"github.com/hatchet-dev/hatchet/pkg/repository/postgres/sqlchelpers"
)
@@ -376,8 +379,23 @@ func (t *APIServer) registerSpec(g *echo.Group, spec *openapi3.T) (*populator.Po
event, err := config.APIRepository.Event().GetEventById(timeoutCtx, id)
if err != nil {
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
return nil, "", err
} else if errors.Is(err, pgx.ErrNoRows) {
v1Event, err := t.config.V1.OLAP().GetEvent(timeoutCtx, id)
if err != nil {
return nil, "", err
}
event = &dbsqlc.Event{
ID: v1Event.ExternalID,
TenantId: v1Event.TenantID,
Data: v1Event.Payload,
CreatedAt: pgtype.Timestamp(v1Event.SeenAt),
AdditionalMetadata: v1Event.AdditionalMetadata,
Key: v1Event.Key,
}
}
return event, sqlchelpers.UUIDToStr(event.TenantId), nil