Skip to content

Commit 6b7d00d

Browse files
session: fix kvdb & sql session store difference
When a session has a MacaroonRecipe set, which has a nil value set for either the `Permissions` or the `Caveats` field, the kvdb session store would return that field as nil, while the sql prior to this commit would return an empty array. When the we migrate the session store from kvdb to sql, that will cause the kvdb and the migrate session store to differ when comparing them, which will cause the migration to fail. This commit fixes that by ensuring that the sql session store returns a nil value for those fields in that scenario, rather than an empty array.
1 parent dfd0931 commit 6b7d00d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

session/sql_store.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,12 @@ func unmarshalSession(ctx context.Context, db SQLQueries,
745745

746746
var macRecipe *MacaroonRecipe
747747
if perms != nil || caveats != nil {
748-
macRecipe = &MacaroonRecipe{
749-
Permissions: unmarshalMacPerms(perms),
750-
Caveats: unmarshalMacCaveats(caveats),
748+
macRecipe = &MacaroonRecipe{}
749+
if perms != nil {
750+
macRecipe.Permissions = unmarshalMacPerms(perms)
751+
}
752+
if caveats != nil {
753+
macRecipe.Caveats = unmarshalMacCaveats(caveats)
751754
}
752755
}
753756

0 commit comments

Comments
 (0)