Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-handle-html-upload-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Handle HTML upload error

We had a bug where the upload error was not handled correctly when the server returned an HTML error.
This caused the upload to fail and the user to not be able to see details about the upload.

https://github.com/owncloud/web/pull/13127
13 changes: 12 additions & 1 deletion packages/web-pkg/src/services/uppy/uppyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Language } from 'vue3-gettext'
import { eventBus } from '../eventBus'
import DropTarget from '@uppy/drop-target'
import { Resource, urlJoin } from '@ownclouders/web-client'
import { Body, generateFileID, MinimalRequiredUppyFile } from '@uppy/utils'
import { Body, generateFileID, MinimalRequiredUppyFile, NetworkError } from '@uppy/utils'

type UppyServiceTopics =
| 'uploadStarted'
Expand Down Expand Up @@ -177,6 +177,12 @@ export class UppyService {
return true
}
return next(err)
},
onAfterResponse(_, res) {
const status = res.getStatus()
if (status >= 500 && res.getHeader('content-type')?.includes('text/html')) {
throw new NetworkError(`Server error (${status}) - Please try again`)
}
}
}

Expand All @@ -203,6 +209,11 @@ export class UppyService {
timeout,
getResponseData() {
return {}
},
onAfterResponse(xhr) {
if (xhr.status >= 500 && xhr.getResponseHeader('content-type')?.includes('text/html')) {
throw new NetworkError(`Server error (${xhr.status}) - Please try again`, xhr)
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/web-runtime/src/components/UploadBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,8 @@ const getUploadItemMessage = (item: UploadResult) => {
errorMessage: string | null
} => {
const responseCode = errorMessage.match(/response code: (\d+)/)?.[1]
const errorBody = JSON.parse(
errorMessage.match(/response text: ([\s\S]+?), request id/)?.[1] || '{}'
)
const responseText = errorMessage.match(/response text: ([\s\S]+?), request id/)?.[1]
const errorBody = JSON.parse(responseText?.startsWith('{') ? responseText : '{}')

return {
responseCode: responseCode ? parseInt(responseCode) : null,
Expand Down Expand Up @@ -756,6 +755,7 @@ onMounted(() => {
uploads.value[file.meta.uploadId].status = 'error'
errors.value[file.meta.uploadId] = error as HttpError
filesInProgressCount.value -= 1
runningUploads.value -= 1

if (file.meta.topLevelFolderId) {
handleTopLevelFolderUpdate(file, 'error')
Expand Down