nextcloud / nextcloud/viewer

Opening an unsupported mime file freezes the UI

Open
#1,579 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage bug good first issue
Dominant language
JavaScript
Stars
119
Forks
72
Avg merge
18h 42m
Merged PRs (30d)
24

Description

Describe the bug

Opening an unsupported mime file from the file view freeze on the wait icon, with no error message displayed to the user

To Reproduce

Run the following in console while browsing files:

OCA.Viewer.open({path:'/path/to/unuspported-mime.type'})

The console reports:

Viewer.vue:450 TypeError: Cannot read properties of undefined (reading 'theme')
    at Viewer.vue:399:1
    at u (runtime.js:63:40)
    at Generator._invoke (runtime.js:294:22)
    at Generator.next (runtime.js:119:21)
    at Vm (Download.vue?b226:19:33)
    at i (Download.vue?b226:19:33)

Probable fix

Seems that in Viewer.vue - https://github.com/nextcloud/viewer/blame/22e47429df029eeb2f36e2361f49e59768dec725/src/views/Viewer.vue#L559 , the use of the handler variable should be swapped with its verification:

			this.theme = handler.theme ?? 'dark'               // Moving that after the if to bring back error message 
			// if we don't have a handler for this mime, abort
			if (!handler) {
				logger.error('The following file could not be displayed', { fileInfo })
				showError(t('viewer', 'There is no plugin available to display this file type'))
				this.close()
				return
			}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/views/Viewer.vue around the handler check identified in the issue, then reproduce the problem with OCA.Viewer.open({path:'/path/to/unuspported-mime.type'}) while browsing files. Verify that an unsupported MIME type no longer causes the UI to freeze and instead displays the reported error message and closes the viewer.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.