Skip to content

fix: correct deserialization order of sequence/routine/membership in …#2694

Merged
jennifersp merged 1 commit into
dolthub:mainfrom
lignumqt:issue-2693
May 5, 2026
Merged

fix: correct deserialization order of sequence/routine/membership in …#2694
jennifersp merged 1 commit into
dolthub:mainfrom
lignumqt:issue-2693

Conversation

@lignumqt

@lignumqt lignumqt commented May 5, 2026

Copy link
Copy Markdown

…auth

The serialize() function wrote fields in this order:
tablePrivileges → sequencePrivileges → routinePrivileges → roleMembership

But deserializeV1() read them in a different order:
tablePrivileges → roleMembership → routinePrivileges → sequencePrivileges

This mismatch went unnoticed because all three sections (sequencePrivileges, routinePrivileges, roleMembership) have the same zero-value byte representation (count=0) when no privileges exist. Once GRANT ALL PRIVILEGES ON ALL ROUTINES or GRANT ALL PRIVILEGES ON ALL FUNCTIONS is executed, routinePrivileges becomes non-empty, the reader offset shifts, and doltgres panics with an index out of range error on the next startup when attempting to read the persisted auth file.

Fix deserializeV1() to match the order used by serialize().

Fixes #2693

…auth

The serialize() function wrote fields in this order:
  tablePrivileges → sequencePrivileges → routinePrivileges → roleMembership

But deserializeV1() read them in a different order:
  tablePrivileges → roleMembership → routinePrivileges → sequencePrivileges

This mismatch went unnoticed because all three sections (sequencePrivileges,
routinePrivileges, roleMembership) have the same zero-value byte representation
(count=0) when no privileges exist. Once GRANT ALL PRIVILEGES ON ALL ROUTINES
or GRANT ALL PRIVILEGES ON ALL FUNCTIONS is executed, routinePrivileges becomes
non-empty, the reader offset shifts, and doltgres panics with an index out of
range error on the next startup when attempting to read the persisted auth file.

Fix deserializeV1() to match the order used by serialize().

Fixes dolthub#2693
@lignumqt

lignumqt commented May 5, 2026

Copy link
Copy Markdown
Author

@jennifersp You have implemented this part of code, please check.

@jennifersp jennifersp left a comment

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.

LGTM!

@jennifersp

Copy link
Copy Markdown
Contributor

Thank you for fixing this error!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic: index out of range in SequencePrivileges.deserialize after GRANT ALL PRIVILEGES ON ALL FUNCTIONS/ROUTINES

3 participants