Skip to content

fix: harden capabilities deserialization when sharing fields are missing#3166

Draft
joshtrichards wants to merge 2 commits intomainfrom
jtr/fix-capabilities-deserialization
Draft

fix: harden capabilities deserialization when sharing fields are missing#3166
joshtrichards wants to merge 2 commits intomainfrom
jtr/fix-capabilities-deserialization

Conversation

@joshtrichards
Copy link
Copy Markdown
Member

Summary

Refactor CapabilitiesDeserializer to safely handle partial files_sharing capability payloads, especially when Share API or public sharing is disabled. Previously merged PR #2803 helped, but did not cover all edge cases.

Changes

  • split capability parsing into smaller helper methods
  • use api_enabled as a gate for share-specific parsing
  • avoid assuming optional files_sharing fields are always present
  • preserve model defaults when fields like default_permissions or public.password are missing
  • rename/update the misleading sharing test
  • add regression tests for:
    • Share API disabled responses
    • missing default_permissions
    • missing ederation
    • public sharing disabled without password fields

Why

The server can legitimately omit parts of files_sharing depending on configuration. The previous deserializer assumed those fields always existed, which could cause crashes during first-time account setup when Share API was disabled or when certain sharing options were turned off.

Result

The app now tolerates partial sharing capability responses and falls back to the existing defaults in Capabilities instead of crashing.

Closes #2815
Closes #3165

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🏁 Checklist

  • 🧪 Tests written, or not not needed

Fixes #3165
Fixes #2815 
...and other already closed duplicate bug reports.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 27, 2026

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 17 complexity

Metric Results
Complexity 17

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions
Copy link
Copy Markdown
Contributor

APK file: https://github.com/nextcloud/notes-android/actions/runs/25006388550/artifacts/6665872202
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes on Android cannot connect to the sever Notes throws error upon first configuration if ShareAPI is disabled

1 participant