Skip to content

Review errors string on E2EE + refactoring (clear old code)#4050

Merged
marinofaggiana merged 16 commits into
masterfrom
e2ee_signature_empty
Mar 31, 2026
Merged

Review errors string on E2EE + refactoring (clear old code)#4050
marinofaggiana merged 16 commits into
masterfrom
e2ee_signature_empty

Conversation

@marinofaggiana
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
@marinofaggiana marinofaggiana changed the title Review error on E2EE Review errors string on E2EE Mar 31, 2026
@marinofaggiana marinofaggiana changed the title Review errors string on E2EE Review errors string on E2EE + refactoring Mar 31, 2026
@marinofaggiana marinofaggiana changed the title Review errors string on E2EE + refactoring Review errors string on E2EE + refactoring (clear old code) Mar 31, 2026
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
@mpivchev mpivchev requested a review from Copilot March 31, 2026 14:39
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors end-to-end encryption (E2EE) error handling by replacing the generic _e2e_error_ string with more specific localized error messages, updates some E2EE flow logic (including folder creation metadata updates), and introduces a new indeterminate HUD banner view for long-running operations.

Changes:

  • Replace generic E2EE error strings with granular _e2ee_* localized messages and update call sites accordingly.
  • Refactor E2EE create-folder flow to update/upload metadata and optionally show a blocking indeterminate HUD banner.
  • Adjust E2EE version handling (support 2.2, broaden version matching), and add a new SwiftUI/LucidBanner HUD view.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Nextcloud.xcodeproj/project.pbxproj Adds new HUD view source file and changes NextcloudKit dependency requirement to a branch.
iOSClient/Supporting Files/en.lproj/Localizable.strings Removes _e2e_error_ and adds specific _e2ee_* error strings plus a create-folder progress string.
iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift Replaces generic E2EE error string with specific localized error keys.
iOSClient/Networking/E2EE/NCNetworkingE2EERename.swift Uses localized _e2ee_no_dir_ instead of generic error key.
iOSClient/Networking/E2EE/NCNetworkingE2EEDelete.swift Uses localized _e2ee_no_dir_ instead of generic error key.
iOSClient/Networking/E2EE/NCNetworkingE2EECreateFolder.swift Refactors folder creation, adds HUD handling, and extracts metadata update logic.
iOSClient/Networking/E2EE/NCNetworkingE2EE.swift Broadens E2EE API version matching and localizes directory-not-found error.
iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift Improves/standardizes E2EE v2 metadata encode/decode errors and signature handling; updates version fields.
iOSClient/Networking/E2EE/NCEndToEndMetadataV1.swift Uses more specific localized decode/checksum error strings.
iOSClient/Networking/E2EE/NCEndToEndMetadata.swift Updates directory-not-found error string and changes decode error messaging.
iOSClient/NCGlobal.swift Adds E2EE compatibility for 2.2 and broadens “version 2” detection.
iOSClient/Menu/NCContextMenuMain.swift Removes a hard-coded _e2e_error_ title argument when showing an error banner.
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift Changes post-transfer behavior for E2EE items to reload instead of pushing a single metadata item.
iOSClient/GUI/Lucid Banner/HudIndeterminateBannerView.swift Adds a new SwiftUI indeterminate HUD banner implementation using LucidBanner.
iOSClient/Files/NCFiles.swift Refactors folder read flow and E2EE metadata handling (includes a compile-breaking regression).
iOSClient/Data/NCManageDatabase+E2EE.swift Changes stored v2 metadata version default from “2.0” to “2”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Nextcloud.xcodeproj/project.pbxproj Outdated
Comment on lines +6121 to +6122
branch = "e2ee-lowercased";
kind = branch;
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SwiftPM dependency for NextcloudKit was changed from a pinned version to a branch ("e2ee-lowercased"). Using a moving branch makes builds non-reproducible and can unexpectedly break CI/releases; prefer pinning to an exact tag/semantic version or a specific revision/commit hash (if a prerelease is needed).

Suggested change
branch = "e2ee-lowercased";
kind = branch;
kind = revision;
revision = 0123456789abcdef0123456789abcdef01234567;

Copilot uses AI. Check for mistakes.
Comment on lines 290 to 293
if let metadataFolder {
self.metadataFolder = metadataFolder.detachedCopy()
self.richWorkspaceText = metadataFolder.richWorkspace
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metadataFolder is referenced here but is no longer defined after switching to resultsReadFolder; this should use resultsReadFolder.metadataFolder (or destructure the tuple) before accessing it, otherwise the file won’t compile.

Copilot uses AI. Check for mistakes.
guard let directory = await self.database.getTableDirectoryAsync(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", session.account, serverUrl)) else {
return NKError(errorCode: global.errorUnexpectedResponseFromDB, errorDescription: NSLocalizedString("_e2e_error_", comment: ""))
error = NKError(errorCode: global.errorUnexpectedResponseFromDB,
errorDescription: NSLocalizedString("_e2ee_no_dir_", comment: ""))
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard failure for fileNameFolder.isEmpty returns _e2ee_no_dir_ ("cannot get directory"), but this branch is about an invalid/empty folder name rather than a missing directory. Use a more accurate localized error key/message (and ideally a more appropriate error code) for the empty-name case.

Suggested change
errorDescription: NSLocalizedString("_e2ee_no_dir_", comment: ""))
errorDescription: NSLocalizedString("_e2ee_invalid_folder_name_", comment: ""))

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +31
defer {
if let banner, let token {
if error == .success {
completeHudIndeterminateBannerSuccess(token: token, banner: banner)
} else {
banner.dismiss()
}
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the defer block, dismissal is gated on token being non-nil (if let banner, let token), but banner.dismiss() does not use token. If token is unexpectedly nil, the HUD could remain visible; consider unwrapping only banner for dismissal, and only require token when calling the completion/update APIs that need it.

Copilot uses AI. Check for mistakes.
NCEndToEndEncryption.shared().encodedkey(&key, initializationVector: &initializationVector)
guard let key = key as? String, let initializationVector = initializationVector as? String else {
return NKError(errorCode: global.errorE2EEEncodedKey,
errorDescription: NSLocalizedString("_e2ee_no_generate_key_", comment: ""))
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

encodedkey(&key, initializationVector: ...) failure is reported with _e2ee_no_generate_key_, but the error code is errorE2EEEncodedKey and the failure is about missing/invalid encoded key/IV (not key generation). This should use the corresponding encoded-key localized message (e.g. _e2ee_no_enc_key_) to avoid confusing users.

Suggested change
errorDescription: NSLocalizedString("_e2ee_no_generate_key_", comment: ""))
errorDescription: NSLocalizedString("_e2ee_no_enc_key_", comment: ""))

Copilot uses AI. Check for mistakes.
guard let directory = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", session.account, serverUrl)) else {
return (nil, nil, 0, NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB, errorDescription: "_e2e_error_"))
return (nil, nil, 0, NKError(errorCode: NCGlobal.shared.errorUnexpectedResponseFromDB,
errorDescription: NSLocalizedString("_e2ee_no_session_", comment: "")))
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the directory lookup fails in encodeMetadata, the code returns _e2ee_no_session_ even though the failing condition is "no directory for (account, serverUrl)". This error message should match the actual failure (likely _e2ee_no_dir_) to avoid misleading diagnostics.

Suggested change
errorDescription: NSLocalizedString("_e2ee_no_session_", comment: "")))
errorDescription: NSLocalizedString("_e2ee_no_dir_", comment: "")))

Copilot uses AI. Check for mistakes.
Comment on lines 37 to 41
func decodeMetadata(_ metadata: String, signature: String?, serverUrl: String, session: NCSession.Session) async -> NKError {
guard let data = metadata.data(using: .utf8), let directory = self.database.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", session.account, serverUrl)) else {
return (NKError(errorCode: NCGlobal.shared.errorE2EEJSon, errorDescription: "_e2e_error_"))
return (NKError(errorCode: NCGlobal.shared.errorE2EEJSon, errorDescription: "Unable to decode the metadata file"))
}

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decodeMetadata returns a hard-coded English error description ("Unable to decode the metadata file"). Since this is user-facing and the rest of the E2EE errors are localized, this should use a NSLocalizedString key (and ideally reuse one of the new _e2ee_* keys) for consistent localization.

Copilot uses AI. Check for mistakes.

// --------------------------------------------------------------------------------------------
// MARK: Ecode JSON Metadata V2.0
// MARK: Ecode JSON Metadata V2
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: the section header says "Ecode JSON Metadata V2"; this looks like a typo for "Encode".

Suggested change
// MARK: Ecode JSON Metadata V2
// MARK: Encode JSON Metadata V2

Copilot uses AI. Check for mistakes.
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
Signed-off-by: Marino Faggiana <marino.faggiana@nextcloud.com>
@marinofaggiana marinofaggiana merged commit 62c58ac into master Mar 31, 2026
4 checks passed
@marinofaggiana marinofaggiana deleted the e2ee_signature_empty branch March 31, 2026 15:00
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.

2 participants