chore: replace sso_connection_id with workos_id in queries and app code#2246
chore: replace sso_connection_id with workos_id in queries and app code#2246
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🦋 Changeset detectedLatest commit: 2c5516b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
6003dcd to
c08599c
Compare
e7aac86 to
bc914ea
Compare
bc914ea to
aee305f
Compare
🚀 Preview Environment (PR #2246)Preview URL: https://pr-2246.dev.getgram.ai
Gram Preview Bot |
This comment has been minimized.
This comment has been minimized.
aee305f to
54ccee2
Compare
54ccee2 to
729cb08
Compare
729cb08 to
0617c5f
Compare
| type Organization struct { | ||
| ID string | ||
| Name string | ||
| Slug string | ||
| WorkosID *string | ||
| UserWorkspaceSlugs []string | ||
| } |
There was a problem hiding this comment.
📝 Info: Cache serialization compatibility with new Organization type
The CachedUserInfo.Organizations field changed from []auth.OrganizationEntry to []sessions.Organization. The Redis cache uses msgpack serialization (via go-redis/cache). Old cached entries have fields like SsoConnectionID and Projects that don't exist in the new type, while the new type has WorkosID which doesn't exist in old data. This is safe because msgpack (like JSON) ignores unknown fields and zero-initializes missing ones. WorkosID will be nil for old cached entries, which is acceptable since it's *string. The 15-minute cache TTL (server/internal/auth/sessions/types.go:12) means old entries will naturally expire quickly after deployment.
Was this helpful? React with 👍 or 👎 to provide feedback.
0617c5f to
c89c02a
Compare
| }) | ||
| } | ||
|
|
||
| // write through organization metadata when not from cache to keep entries updated | ||
| // TODO: there may be a better place to do this | ||
| if !fromCache { | ||
| if _, err := s.orgRepo.UpsertOrganizationMetadata(ctx, orgRepo.UpsertOrganizationMetadataParams{ | ||
| ID: org.ID, | ||
| Name: org.Name, | ||
| Slug: org.Slug, | ||
| SsoConnectionID: conv.PtrToPGText(org.SsoConnectionID), | ||
| Whitelisted: pgtype.Bool{Bool: false, Valid: false}, | ||
| }); err != nil { | ||
| return nil, oops.E(oops.CodeUnexpected, err, "error upserting organization metadata").Log(ctx, s.logger) | ||
| } | ||
| } | ||
|
|
||
| organizations = append(organizations, &gen.OrganizationEntry{ | ||
| ID: org.ID, | ||
| Name: org.Name, | ||
| Slug: org.Slug, | ||
| SsoConnectionID: org.SsoConnectionID, | ||
| UserWorkspaceSlugs: org.UserWorkspaceSlugs, | ||
| Projects: orgProjects, | ||
| }) |
There was a problem hiding this comment.
📝 Info: Info method no longer upserts org metadata on cache miss — equivalent behavior
The Info method removed the !fromCache upsert loop that previously wrote org metadata on every cache miss. This is equivalent because GetUserInfo on cache miss calls GetUserInfoFromSpeakeasy → syncOrgsAndWorkOSIDs, which upserts all orgs. The old code's fromCache variable (now _ at line 295) was used to conditionally run the upsert. The new code achieves the same effect implicitly — org metadata is always upserted when fetching fresh data from the IDP.
Was this helpful? React with 👍 or 👎 to provide feedback.
| --- | ||
| "server": patch | ||
| --- | ||
|
|
||
| Remove the legacy column sso_connection_id |
There was a problem hiding this comment.
🚩 sso_connection_id column not dropped from schema despite changeset title
The changeset at .changeset/petite-cooks-like.md says 'Remove the legacy column sso_connection_id', but the database schema (server/database/schema.sql:54) still has the sso_connection_id column, and no migration drops it. The PR only removes code that WRITES to the column. The generated sqlc code (e.g., server/internal/organizations/repo/queries.sql.go:359) still scans sso_connection_id from SELECT * queries. This is likely intentional (gradual deprecation), but the changeset title is misleading. A follow-up migration will be needed to actually drop the column.
Was this helpful? React with 👍 or 👎 to provide feedback.
c89c02a to
a8f75b1
Compare
a8f75b1 to
63acce0
Compare
…ication code Introduce sessions.Organization as an internal type to decouple the cached user info from the Goa API surface. The Speakeasy IDP's workos_id field now flows through to organization_metadata.workos_id via the upsert. Removes sso_connection_id from the Goa OrganizationEntry design and cleans up the frontend reference. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63acce0 to
2c5516b
Compare
Remove all dependencies on
sso_connection_id, there are no more dependencies on it and it seems to confuse humans and Claude alike. This PR changes behavior to targetworkos_idas a column instead ofsso_connection_id. After we merge it, we should run the following data migration:There is a follow-up PR to drop the column. We first merge the behavior change and let it run for a couple days to avoid risks of data loss.