Skip to content

Refactor: Attempt II at removing pgtype.UUID everywhere + convert string UUIDs into uuid.UUID#2894

Merged
mrkaye97 merged 50 commits intomainfrom
mk/pgtype-uuid-attempt-2
Feb 3, 2026
Merged

Refactor: Attempt II at removing pgtype.UUID everywhere + convert string UUIDs into uuid.UUID#2894
mrkaye97 merged 50 commits intomainfrom
mk/pgtype-uuid-attempt-2

Conversation

@mrkaye97
Copy link
Copy Markdown
Contributor

@mrkaye97 mrkaye97 commented Jan 30, 2026

Description

Attempt 2 at #2581

The main goal here was to replace pgtype.UUID with uuid.UUID everywhere. This uncovered a handful of small bugs (especially in some of our queries) where we were relying on pgtype.UUID semantics to tell the difference between a null value and a non-null value, which breaks with a more restrictive type (e.g. not using sqlc.narg in queries and just implicitly allowing @foobar::UUID to be nullable via pgtype.UUID).

I also got a little greedy, so I tried my best to replace all instances of string uuids everywhere with uuid.UUID too. Should help a lot with type safety everywhere, and limit the amount of type casting we're doing

I feel pretty good about this with all the tests passing and such, but it's pretty likely there are at least one or two bugs or commands or some such that are broken, so will need to track those down incrementally I think

Type of change

  • Refactor (non-breaking changes to code which doesn't change any behaviour)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hatchet-docs Ready Ready Preview, Comment Feb 3, 2026 4:13pm

Request Review


resp[i] = gen.WorkerLabel{
Metadata: *toAPIMetadata(id, labels[i].CreatedAt.Time, labels[i].UpdatedAt.Time),
// fixme: `id` needs to be a uuid
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixme?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for later, we discussed on slack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see fixme --> write fixme?

@@ -38,7 +37,7 @@ func (p *OperationPool[T]) SetTenants(tenants []*sqlcv1.Tenant) {
tenantMap := make(map[string]bool)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this just be map[uuid.UUID]bool?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah maybe - I was trying not to mess with the operation pool stuff too much because of all the generics and reflection going on here, figured we could clean this up later

@mrkaye97 mrkaye97 merged commit 058968c into main Feb 3, 2026
45 checks passed
@mrkaye97 mrkaye97 deleted the mk/pgtype-uuid-attempt-2 branch February 3, 2026 16:03
Comment thread pkg/repository/match.go
if match.SignalExternalID != nil {
externalIds = append(externalIds, *match.SignalExternalID)
} else {
externalIds = append(externalIds, uuid.Nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment thread pkg/repository/olap.go
}

outputPayload, exists := externalIdToPayload[dag.OutputEventExternalID]
outputEventExternalId := uuid.Nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

Comment thread pkg/repository/olap.go

for i, row := range rows {
externalIds[i] = row.EventExternalID
eventExternalId := uuid.Nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect

Comment thread pkg/repository/olap.go

for _, row := range rows {
payload, exists := payloads[row.EventExternalID]
eventExternalId := uuid.Nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect

Comment thread pkg/repository/olap.go
eventCount = int(row.Count)
}

latestWorkerId := uuid.Nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants