Skip to content

fix(volume-backups): clear retention amount when the field is emptied - #5077

Open
NoiceHax wants to merge 2 commits into
Dokploy:canaryfrom
NoiceHax:fix/issue-4184
Open

fix(volume-backups): clear retention amount when the field is emptied#5077
NoiceHax wants to merge 2 commits into
Dokploy:canaryfrom
NoiceHax:fix/issue-4184

Conversation

@NoiceHax

@NoiceHax NoiceHax commented Aug 14, 2026

Copy link
Copy Markdown

Clearing "Keep Latest Backups" did not remove the limit. The submit handler worked out a null for the empty field and then turned it straight back into undefined with ?? undefined. Drizzle leaves undefined columns out of the UPDATE, so the old count stayed in the database and kept pruning backups the user thought were being kept.

It now sends the null, which is what the database backup form already does. I moved that bit of normalizing into a small helper so it can be tested.

The input's onChange also used to drop anything that was not all digits, so typing 3.5 left the last good number sitting in the form state. It now passes the raw value to the schema, which rejects it and shows an error instead.

To check by hand: set a retention value, save, reload, then clear the field and save. It should stay empty. Tests are in apps/dokploy/test/utils/volume-backup-retention.test.ts.

Closes #4184

Clearing "Keep Latest Backups" computed a `null` retention and then
immediately mapped it back with `?? undefined` before calling the
mutation. Drizzle omits `undefined` columns from the generated UPDATE,
so `keepLatestCount` was never written and the previous limit kept
pruning backups the user believed were retained forever. Send the
explicit `null` instead, matching how the database backup form already
handles the same field, and move the normalization into a small pure
helper so it can be covered by a test.

Closes Dokploy#4184
@NoiceHax
NoiceHax requested a review from Siumauricio as a code owner August 14, 2026 05:07
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 14, 2026
return null;
}

return value ?? null;

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.

P1 Nonempty input clears retention limit

When an existing limit is cleared and replaced with a non-integer value such as 3.5, the input handler leaves the parsed form value undefined while retaining the nonempty raw value. This fallback converts that state to null, silently disabling backup pruning instead of rejecting the invalid value.

Knowledge Base Used: Backups and Schedules

…ng it

The number input dropped anything that was not a whole number, so a
non-empty but invalid value like "3.5" left the parsed form value
undefined while the raw input stayed non-empty. prepareKeepLatestCount
turned that into an explicit null, which silently disabled pruning.

Pass the raw value to the form so the schema rejects it and the user
gets a validation message. prepareKeepLatestCount now returns undefined
for that state so the update leaves the stored retention untouched.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 14, 2026
@NoiceHax

Copy link
Copy Markdown
Author

Fixed the invalid-input case from the review. The number input used to swallow anything that was not a whole number, so a non-empty value like 3.5 left the form value undefined and the helper turned that into an explicit null, wiping the retention limit.

Now the raw value goes straight to the form, so the schema rejects it and the user sees "Must be a whole number" instead. prepareKeepLatestCount returns undefined for that state, so even if it is reached the stored retention is left alone rather than cleared. Test updated to cover it.

Ran the suite locally: apps/dokploy test/utils/volume-backup-retention.test.ts passes (4 tests), and tsc --noEmit on apps/dokploy is clean.

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

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resetting backup retention amount on volume backups to undefined (= unlimited) does not work

1 participant