Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend): standardize error message handling by truncating to the first segment to hide system paths

johavenf8e6f249c158
diff --git a/backend/src/applications/files/services/files-methods.service.ts b/backend/src/applications/files/services/files-methods.service.ts
index e5619734..0f369a91 100644
--- a/backend/src/applications/files/services/files-methods.service.ts
+++ b/backend/src/applications/files/services/files-methods.service.ts
@@ -177,11 +177,12 @@ export class FilesMethods {
private handleError(space: SpaceEnv, action: string, e: any, dstSpace?: SpaceEnv) {
this.logger.error(`unable to ${action} ${space.url}${dstSpace?.url ? ` -> ${dstSpace.url}` : ''} : ${e}`)
+ const errorMsg = e.message.split(',')[0]
if (e instanceof LockConflict) {
throw new HttpException('The file is locked', HttpStatus.LOCKED)
} else if (e instanceof FileError) {
- throw new HttpException(e.message, e.httpCode)
+ throw new HttpException(errorMsg, e.httpCode)
}
- throw new HttpException(e.message, HttpStatus.INTERNAL_SERVER_ERROR)
+ throw new HttpException(errorMsg, HttpStatus.INTERNAL_SERVER_ERROR)
}
}
diff --git a/backend/src/applications/sync/services/sync-manager.service.ts b/backend/src/applications/sync/services/sync-manager.service.ts
index b99e046c..c5e69895 100644
--- a/backend/src/applications/sync/services/sync-manager.service.ts
+++ b/backend/src/applications/sync/services/sync-manager.service.ts
@@ -266,11 +266,12 @@ export class SyncManager {
private handleError(space: SpaceEnv, action: string, e: any, dstSpace?: SpaceEnv) {
this.logger.error(`unable to ${action} ${space.url}${dstSpace?.url ? ` -> ${dstSpace.url}` : ''} : ${e}`)
+ const errorMsg = e.message.split(',')[0]
if (e instanceof LockConflict) {
throw new HttpException('The file is locked', HttpStatus.LOCKED)
} else if (e instanceof FileError) {
- throw new HttpException(e.message, e.httpCode)
+ throw new HttpException(errorMsg, e.httpCode)
}
- throw new HttpException(e.message, HttpStatus.INTERNAL_SERVER_ERROR)
+ throw new HttpException(errorMsg, HttpStatus.INTERNAL_SERVER_ERROR)
}
}
diff --git a/backend/src/applications/webdav/services/webdav-methods.service.ts b/backend/src/applications/webdav/services/webdav-methods.service.ts
index 74bfdf13..4287c747 100644
--- a/backend/src/applications/webdav/services/webdav-methods.service.ts
+++ b/backend/src/applications/webdav/services/webdav-methods.service.ts
@@ -463,11 +463,12 @@ export class WebDAVMethods {
private handleError(req: FastifyDAVRequest, res: FastifyReply, e: any, toUrl?: string) {
this.logger.error(`Unable to ${req.method} ${req.dav.url}${toUrl ? ` -> ${toUrl}` : ''} : ${e.message}`)
+ const errorMsg = e.message.split(',')[0]
if (e instanceof LockConflict) {
return DAV_ERROR_RES(HttpStatus.LOCKED, PRECONDITION.LOCK_CONFLICT, res, e.lock.davLock?.lockroot || e.lock.dbFilePath)
} else if (e instanceof FileError) {
- return res.status(e.httpCode).send(e.message)
+ return res.status(e.httpCode).send(errorMsg)
}
- throw new HttpException(e.message, HttpStatus.INTERNAL_SERVER_ERROR)
+ throw new HttpException(errorMsg, HttpStatus.INTERNAL_SERVER_ERROR)
}
}