[18][FIX] server_environment_data_encryption: keep sibling env fields cache consistent - #293
Open
florian-dacosta wants to merge 1 commit into
Open
[18][FIX] server_environment_data_encryption: keep sibling env fields cache consistent#293florian-dacosta wants to merge 1 commit into
florian-dacosta wants to merge 1 commit into
Conversation
…he consistent
Writing one env-managed field left the cache of the other env fields stale: they are non-stored computed fields with no field dependency on the encrypted storage, so writing (via the inverse) did not recompute them. A constraint validating a sibling field then read a stale/empty value and raised incorrectly (e.g. microsoft_outlook checking smtp_encryption while saving smtp_authentication).
After storing a value, refresh the cache of the sibling env fields from the values just written, skipping fields already in cache so that a multi-field write keeps each fields freshly assigned value.
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.
server.env.mixin env fields are non-stored computed fields whose value is read from encrypted.data. They have no field dependency on that storage, so writing one of them (through the inverse) does not recompute the others. In the web client save flow, a constraint that reads a sibling env field (e.g. microsoft_outlook validating smtp_encryption/smtp_user while smtp_authentication is saved) then sees a stale/empty value and raises a spurious ValidationError.
In _inverse_server_env, after storing the new value, refresh the cache of the sibling env fields from the values just written. Fields already present in cache are left untouched so a multi-field write does not clobber the freshly assigned values.
Steps to reproduce : install Odoo with microsf_outlook module.

Set the Connection Encryption to TLS and save.
Then select outlook on the "Authenticate with" field and save => You'll get a validation error from a constraint about the Connection Encryption that must be with TLS value, while it actually already is...