[18.0][FIX] auto_backup: open cached dump in binary mode#3659
Open
sebastienclaude wants to merge 1 commit into
Open
[18.0][FIX] auto_backup: open cached dump in binary mode#3659sebastienclaude wants to merge 1 commit into
sebastienclaude wants to merge 1 commit into
Conversation
When several `db.backup` records use `method=local`, only the first one
performs the actual dump; the subsequent local records copy the file
written by the first via `shutil.copyfileobj(cached, destiny)`.
The source file `cached` was opened with `open(backup)`, which defaults
to text mode. Python then tries to UTF-8 decode the binary dump (ZIP or
SQL with non-UTF-8 bytes) and aborts with::
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in
position 12: invalid continuation byte
The destination is already opened with `"wb"`, so the fix is to open
the cached source with `"rb"` too.
Reproduced and fixed on a production instance with two `db.backup`
records both in `method=local` (local disk + CIFS mount). After the
patch the second copy is byte-identical to the first dump.
The same defect is present on branches 16.0 and 17.0 of this module.
Signed-off-by: sebastienclaude <44704752+sebastienclaude@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
When several
db.backuprecords usemethod=local, only the first one performs the actual dump; the subsequent local records copy the file written by the first viashutil.copyfileobj(cached, destiny)inDbBackup.action_backup.The source file
cachedis opened withopen(backup), which defaults to text mode. Python then tries to UTF-8 decode the binary dump (ZIP archive or SQL stream containing non-UTF-8 bytes) and aborts with:Symptom from the
backup_logmail alert:Fix
The destination is already opened with
"wb", so the fix is to open the cached source with"rb"too:Reproduction / validation
Reproduced on an Odoo 18 instance with two
db.backuprecords, bothmethod=local(one to a local disk, one to a CIFS-mounted share). Before the patch the second copy was a zero-byte file and the cron failed nightly. After the patch the second copy is byte-identical to the first dump (110 MB ZIP, same SHA), and no furtherUnicodeDecodeErroris raised.Other branches
The same defect is present on branches 16.0 and 17.0 of this module (identical code). Happy to open backport PRs if requested.