Skip to content

fix(nextcloud_occ_app_config): compare array values as JSON (idempotency)#272

Merged
markuslf merged 1 commit into
mainfrom
fix/nextcloud-occ-app-config-array-idempotency
May 25, 2026
Merged

fix(nextcloud_occ_app_config): compare array values as JSON (idempotency)#272
markuslf merged 1 commit into
mainfrom
fix/nextcloud-occ-app-config-array-idempotency

Conversation

@markuslf
Copy link
Copy Markdown
Member

Last of the deferred behavior-changing fixes.

Bug

For an array config value the module compared str(<python list>) (e.g. "['alpha', 'beta']", Python repr with single quotes) against the user's array literal ('["alpha","beta"]'). They never matched, so the module reported changed=true and re-ran occ config:app:set on every run - non-idempotent.

Empirical verification (podman)

Verified against a Nextcloud 33 container:

  • config:app:set core k --value='["alpha","beta"]' --type=array then
  • config:list core --output=json --private returns the value as a parsed JSON array: ["alpha", "beta"] (a Python list).
  • config:app:get core k --details --output=json returns value as the JSON string "[\"alpha\",\"beta\"]" (whitespace-sensitive).

Fix

values_match() compares array values as parsed JSON (both the cached/list path and the live JSON-string path), so equal arrays match regardless of whitespace or Python-vs-JSON quoting. The cached current value is now stored as canonical JSON.

Tests

  • values_match() unit tests (equal-ignoring-whitespace, different, invalid-JSON, non-array).
  • main() via the installed_config_json cache path (no occ needed): an already-set array is idempotent; a differing array reports a change.

Validation

Full tox matrix green (103 tests across 13 envs); ansible-doc renders; pre-commit green.

This completes the deferred behavior-changing fixes (the get_item_by_id contract was dropped: the current by-id "fail if missing" behavior is correct and documented, only the error message is raw - changing it risks the by-name create-on-not-found idempotency).

@markuslf markuslf requested a review from NavidSassan May 25, 2026 08:26
…s JSON

Nextcloud stores an array config value and returns it as a parsed JSON
array (verified against Nextcloud 33: config:list yields
["alpha", "beta"]). The module stringified that list with str()
(Python repr, single quotes) and compared it against the user's array
literal, which never matched - so the module reported a change and
re-ran config:app:set on every run.

Compare array values as parsed JSON instead (values_match()), and store
the cached current value as canonical JSON. Add unit tests for the
helper and for the cached (installed_config_json) idempotency path.

The occ output formats were verified empirically in a Nextcloud podman
container.
@markuslf markuslf force-pushed the fix/nextcloud-occ-app-config-array-idempotency branch from 951b0db to 3831de9 Compare May 25, 2026 08:31
@markuslf markuslf merged commit ddb0af6 into main May 25, 2026
10 checks passed
@markuslf markuslf deleted the fix/nextcloud-occ-app-config-array-idempotency branch May 25, 2026 08:31
ebuerki-lf pushed a commit that referenced this pull request May 26, 2026
…s JSON (#272)

Nextcloud stores an array config value and returns it as a parsed JSON
array (verified against Nextcloud 33: config:list yields
["alpha", "beta"]). The module stringified that list with str()
(Python repr, single quotes) and compared it against the user's array
literal, which never matched - so the module reported a change and
re-ran config:app:set on every run.

Compare array values as parsed JSON instead (values_match()), and store
the cached current value as canonical JSON. Add unit tests for the
helper and for the cached (installed_config_json) idempotency path.

The occ output formats were verified empirically in a Nextcloud podman
container.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant