Repository navigation
Conversation
Older releases stored some policy values with another AppConfig type than the policy API writes today, for example identification_documents and add_footer as boolean or groups_request_sign as array. PolicySource::readSystemValue() requested the type of the policy default first and fell back to other getters on AppConfigTypeConflictException. Nextcloud logs a warning before throwing that exception, so every policy resolution on such an instance logged one or two "is stored as X but was requested as Y" warnings. Look up the stored type first and read the value with it. The values handed to the policy normalizers stay the same as with the previous fallback chain. Resolves: LibreSign#9456 Signed-off-by: no84by <50858621+no84by@users.noreply.github.com>
15 of 18 tasks
This branch has not been deployed
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.
Resolves: #9456
Summary
Since Nextcloud 35,
AppConfiglogs a warning before it throwsAppConfigTypeConflictException.PolicySource::readSystemValue()relied on that exception: it requested the type of the policy default first and fell back to other typed getters on conflict. For values that older releases stored with another type, every policy resolution logged one or two warnings, which is why they appear on every page load.Observed on an affected 15.0.12 / Nextcloud 35.0.3 instance, counted from its log:
libresign/identification_documents is stored as boolean but was requested as arraylibresign/identification_documents is stored as boolean but was requested as stringlibresign/groups_request_sign is stored as array but was requested as stringThe issue also lists
add_footerstored as boolean, which goes through the same path.The existing repair steps (
Version19001Date20261022200000,Version19004Date20261027180000) only fix the type metadata of values that already hold JSON, so a legacy boolean stays as it is, and the reader keeps producing the warnings.This change looks up the stored type with
IAppConfig::getValueType()first and reads the value with that type, so no conflicting getter is called. The values handed to the policy normalizers are the same as with the previous fallback chain:add_footer) is passed on as boolean;identification_documents) still resolves to the policy default;Writers are unchanged:
saveSystemPolicy()already rewrites the key with the normalized type, so saving the policy once in the admin settings also migrates the stored type.How to test
occ config:app:set libresign identification_documents --value=true --type=boolean occ config:app:set libresign add_footer --value=true --type=boolean occ config:app:set libresign groups_request_sign --value='["admin"]' --type=arrayPolicySource::loadSystemPolicy().nextcloud.loggets fiveis stored as ... but was requested as ...warnings per resolution (two each foridentification_documentsandadd_footer, one forgroups_request_sign). After: none, and the resolved values are identical.Validation evidence
What ran (PHP 8.5, Nextcloud server
master36.0.0 dev, SQLite):PolicySourceTest::testLoadSystemPolicyReadsLegacyTypedValueWithItsStoredType(new, four data sets).InMemoryAppConfignow records reads that request another type than the stored one, as Nextcloud logs them. Onmainthree data sets fail with the exact warnings from the issue; with the fix all pass.phpunit --testsuite unit: 4997 tests OK (one unrelated PHP 8.5 deprecation inFileService).Version19001Date20261022200000Test,Version19004Date20261027180000Test,PolicySourceRuleCountTest: 37 tests OK.php-cs-fixer --dry-runon the changed files: clean.psalmonPolicySource.php: no errors.API / Back-end changes
PolicySource::readSystemValue()reads system policy values with their stored AppConfig type instead of probing typed getters.composer openapiwhen necessaryTasks
identification_documents,add_footerandgroups_request_signChecklist
AI (if applicable)