Skip to content

When getting tables to truncate, panic on unknown version#1198

Merged
brandur merged 1 commit intomasterfrom
brandur-panic-unknown-version
Apr 7, 2026
Merged

When getting tables to truncate, panic on unknown version#1198
brandur merged 1 commit intomasterfrom
brandur-panic-unknown-version

Conversation

@brandur
Copy link
Copy Markdown
Contributor

@brandur brandur commented Apr 6, 2026

This one's related to code review feedback here [1]. When getting a list
of tables that need to be truncated for the TestSchema helpers, it was
possible to receive migration versions that didn't exist and the
function would tolerate it, returning the latest known list of tables.
This often works, but even where it does there's some risk of a new
table coming in that doesn't end up getting cleaned up properly.

Here, panic when receiving an unknown version number so that the problem
can be corrected immediately. The panic may seem undesirable, but these
functions are only used in tests, so it should be fine.

[1] https://github.com/riverqueue/riverpro/pull/281#discussion_r3040295326

This one's related to code review feedback here [1]. When getting a list
of tables that need to be truncated for the `TestSchema` helpers, it was
possible to receive migration versions that didn't exist and the
function would tolerate it, returning the latest known list of tables.
This often works, but even where it does there's some risk of a new
table coming in that doesn't end up getting cleaned up properly.

Here, panic when receiving an unknown version number so that the problem
can be corrected immediately. The panic may seem undesirable, but these
functions are only used in tests, so it should be fine.

[1] riverqueue/riverpro#281 (comment)
@brandur brandur requested a review from bgentry April 6, 2026 20:57
@bgentry
Copy link
Copy Markdown
Contributor

bgentry commented Apr 7, 2026

This one's related to code review feedback here [1]. When getting a list
of tables that need to be truncated for the TestSchema helpers, it was
possible to receive migration versions that didn't exist and the
function would tolerate it, returning the latest known list of tables.
This often works, but even where it does there's some risk of a new
table coming in that doesn't end up getting cleaned up properly.

I may have misread the code in question, but I thought it was not returning any pro tables when the version wasn't explicitly listed in the case.

@brandur
Copy link
Copy Markdown
Contributor Author

brandur commented Apr 7, 2026

I may have misread the code in question, but I thought it was not returning any pro tables when the version wasn't explicitly listed in the case.

Yeah I think that's right. Somehow the pro and non-pro versions ended up being implemented differently.

I've run into issues with this non-pro version as well wherein I'd add a table, it wouldn't truncate, and I'd be sitting there trying to figure out wtf is going on. LLMs probably do a good job of this nowadays, but it was vexing, and shows that this could be improved.

I'm thinking let's just change both instances to panics, and since these are test-only it should be fine.

Thanks!

@brandur brandur merged commit 11d80e0 into master Apr 7, 2026
15 checks passed
@brandur brandur deleted the brandur-panic-unknown-version branch April 7, 2026 06:01
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.

2 participants