[FIX] web_pwa_customize: Fix singleton error when loading PWA icon - #3626
Draft
rrebollo wants to merge 1 commit into
Draft
[FIX] web_pwa_customize: Fix singleton error when loading PWA icon#3626rrebollo wants to merge 1 commit into
rrebollo wants to merge 1 commit into
Conversation
When a PNG icon is uploaded, set_values() creates multiple ir.attachment records (base icon + resized versions). Due to a race condition or repeated saves without changes, duplicate attachments with the same URL can accumulate in the database. The get_values() method searches using LIKE which matches all matching attachments and calls .datas on the multi-record recordset, triggering ensure_one() ValueError. Add limit=1 to the search to return only the first matching attachment.
Contributor
|
Hi @victoralmau, |
Member
|
I think you should remove the duplicated attachment instead, as if not, the behavior is nondeterministic. |
rrebollo
marked this pull request as draft
July 29, 2026 16:11
Author
|
I will left this on draft |
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.
In production, multiple
ir.attachmentrecords with the same URL (/web_pwa_customize/icon.svg) were found in the database. The exact cause of the duplication is unknown.The
get_values()method searches for PWA icon attachments usingsearch([("url", "like", "/web_pwa_customize/icon.")]), which in PostgreSQL translates toLIKE '%/web_pwa_customize/icon.%'. This matches all attachments whose URL contains that substring. When multiple attachments match, calling.datason the multi-record recordset triggersensure_one(), raisingValueError: Expected singleton.Steps to reproduce:
ir.attachmentrecords with the same PWA icon URLFull traceback:
Fix: Add
limit=1to the search inget_values()to return only the first matching attachment, preventing the singleton error regardless of how many duplicate attachments exist.@BinhexTeam T12289