Skip to content

[19.0][FIX] server_environment: keep sibling env fields cache consistent - #306

Open
Ricardoalso wants to merge 1 commit into
OCA:19.0from
camptocamp:19.0-fix-server_environment-sibling-cache
Open

Ricardoalso wants to merge 1 commit into
OCA:19.0from
camptocamp:19.0-fix-server_environment-sibling-cache

Conversation

@Ricardoalso

@Ricardoalso Ricardoalso commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Env-computed fields share _compute_server_env and have no field
dependency. While one of them is written, the ORM protects all of them
against recomputation, so a constraint reading a sibling env field that
is not in cache gets an empty value: it raises spuriously or is silently
skipped (e.g. webservice OAuth2 checks seeing auth_type as False).

Before running constraints, compute the protected env fields missing
from cache from the configuration or their stored default. The fields
being written are left alone: if evicted from cache, the ORM writes
them again before their inverse, and filling them from the defaults
would lose their new values. This is also why it is not done in the
inverse.

As env fields are now cached on create and write, the test helper
load_config invalidates the cache when switching the configuration,
otherwise dependent modules' tests read the previous values.

Same approach as OCA/server-env#293 for server_environment_data_encryption.

@Ricardoalso
Ricardoalso marked this pull request as draft October 1, 2026 11:29
@OCA-git-bot OCA-git-bot added mod:server_environment Module server_environment series:19.0 labels Oct 1, 2026
@Ricardoalso
Ricardoalso force-pushed the 19.0-fix-server_environment-sibling-cache branch from be4b8e7 to 0326f18 Compare October 1, 2026 11:48
@Ricardoalso
Ricardoalso force-pushed the 19.0-fix-server_environment-sibling-cache branch 3 times, most recently from 4b00c57 to 4cc8ca5 Compare October 28, 2026 15:46
Env-computed fields share `_compute_server_env` and have no field
dependency. While one of them is written, the ORM protects all of them
against recomputation, so a constraint reading a sibling env field that
is not in cache gets an empty value: it raises spuriously or is silently
skipped (e.g. webservice OAuth2 checks seeing `auth_type` as False).

Before running constraints, compute the protected env fields missing
from cache from the configuration or their stored default. The fields
being written are left alone: if evicted from cache, the ORM writes
them again before their inverse, and filling them from the defaults
would lose their new values. This is also why it is not done in the
inverse.

As env fields are now cached on create and write, the test helper
`load_config` invalidates the cache when switching the configuration,
otherwise dependent modules' tests read the previous values.
@Ricardoalso
Ricardoalso force-pushed the 19.0-fix-server_environment-sibling-cache branch from 4cc8ca5 to 33f5113 Compare October 28, 2026 15:53
@Ricardoalso
Ricardoalso marked this pull request as ready for review October 28, 2026 16:08
@Ricardoalso

Copy link
Copy Markdown
Contributor Author

Hi @rven, I made some changes in here. It should be ready now

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

Labels

mod:server_environment Module server_environment series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants