Bug 457531 - "Malformed URL" when opening Android 12 device with MTP from Disks & Devices widget
Summary: "Malformed URL" when opening Android 12 device with MTP from Disks & Devices ...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.96.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-05 16:46 UTC by Natalie Clarius
Modified: 2022-08-06 15:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
"Malformed URL" error message (8.21 KB, image/png)
2022-08-05 16:46 UTC, Natalie Clarius
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Natalie Clarius 2022-08-05 16:46:15 UTC
Created attachment 151131 [details]
"Malformed URL" error message

SUMMARY
***
When connecting my phone in file transfer mode via USB, the Disks & Devices widget recognizes it, but when trying to open it in the file manager, the attached error message about a malformed URL appears.
***

STEPS TO REPRODUCE
1. Connect a phone via USB and select data transfer mode in phone's connection settings
2. In Disks & Devices widgets, click "Open in File Manager"

OBSERVED RESULT
Error message "Malformed URL udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/." Device doesn't open. 

EXPECTED RESULT
Device opens in file manager, same as when accessing it from Dolphin in Devices panel.

ADDITIONAL INFORMATION
Opening the device from Dolphin works. 

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Kernel Version: 5.18.16-arch1-1 (64-bit)
Comment 1 Nate Graham 2022-08-05 18:38:46 UTC
Cannot reproduce with my phone and git master everything KDE. Does the problem go away if you click "Allow" on your phone's screen before clicking the "Open in File Manager" button in the Disks & Devices popup.
Comment 2 Natalie Clarius 2022-08-05 19:01:41 UTC
(In reply to Nate Graham from comment #1)
> Does the
> problem go away if you click "Allow" on your phone's screen before clicking
> the "Open in File Manager" button in the Disks & Devices popup.

There is no "Allow" button on my phone to click. I only get the notification that it's connected, and when I tap on it to get to USB settings, I select "Data transfer" as the option before clicking the "Open in File Manager" button on my PC.
Comment 3 Natalie Clarius 2022-08-05 19:02:58 UTC
My phone is a Pixel 4a with Android 12.
Comment 4 Nate Graham 2022-08-05 19:31:02 UTC
Thanks. Maybe things are different in newer versions of Android. My crusty old phone is stuck on version 8.
Comment 5 Nicolas Fella 2022-08-05 21:52:38 UTC
If you put "mtp:" in front of the URL and enter that in Dolphin does it do something useful?
Comment 6 Nicolas Fella 2022-08-05 22:02:37 UTC
Please run "solid-hardware5 details udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/" and show the output
Comment 7 Natalie Clarius 2022-08-05 22:43:10 UTC
(In reply to Nicolas Fella from comment #5)
> If you put "mtp:" in front of the URL and enter that in Dolphin does it do
> something useful?

Yes, this correctly opens the device in the same way the entry in the places panel does.

> Please run "solid-hardware5 details udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/" and show the output

> udi = 'udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/'
>   parent = '' (string)
>   vendor = '' (string)
>   product = '' (string)
>   description = '' (string)
>   icon = '' (string)
Comment 8 Natalie Clarius 2022-08-05 22:45:20 UTC
If I leave the 'udi=" part out in the command I get

> udi = '/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/'
>   parent = '/org/kde/solid/udev' (string)
>   vendor = 'Google' (string)
>   product = 'Pixel 4a' (string)
>   description = 'Pixel 4a' (string)
>   icon = 'multimedia-player' (string)
>   Block.major = 189  (0xbd)  (int)
>   Block.minor = 16  (0x10)  (int)
>   Block.device = '/dev/bus/usb/001/017' (string)
>   Camera.supportedProtocols = {'ptp'} (string list)
>   Camera.supportedDrivers = {'gphoto'} (string list)
>   PortableMediaPlayer.supportedProtocols = {'mtp'} (string list)
>   PortableMediaPlayer.supportedDrivers = {'usb'} (string list)
>
Comment 9 Nicolas Fella 2022-08-05 23:10:28 UTC
Does running "kioclient5 exec mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//" work?
Comment 10 Natalie Clarius 2022-08-05 23:17:20 UTC
(In reply to Nicolas Fella from comment #9)
> Does running "kioclient5 exec
> mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//"
> work?

No, this gives me the same error dialog, and the following terminal output:

> kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/mtp" not found
> kf.service.services: KApplicationTrader: mimeType "x-scheme-handler/mtp" not found
> command= "/home/natalie/kde/usr/bin/dolphin" args= ("/home/natalie/kde/usr/bin/dolphin", "mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//")
> kf.kio.core: Protocol Class of url QUrl("mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//") , isn't ':local', cancelling job.
> Copying QUrl("mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//")  to QUrl("file:///home/natalie/.cache/kioexec/krun/183392_0/unnamed")
Comment 11 Nicolas Fella 2022-08-05 23:23:21 UTC
I see you have dolphin built from source. Do you have kio-extras built too?
Comment 12 Natalie Clarius 2022-08-05 23:36:55 UTC
Ah, yes, I had totally forgotten I'm using source-built Dolphin as my default file manager on top of stable everything else. With the regularly installed version of Dolphin it works, so not a bug.  Sorry for the confusion; I'll make sure to first test with vanilla Plasma next time.
Comment 13 Nicolas Fella 2022-08-05 23:54:07 UTC
No problem :)

There is still something weird going on, so there may be a genuine bug somewhere that you uncovered

What happens is roughly this:
- Plasma calls kioclient5 exec mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//
- KIO (OpenUrlJob in particular) checks which app should be used to open mtp: URLs. The mtp worker for kio is provided by kio-extras, that's why I was asking whether that is installed
- KIO doesn't find any app that handles mtp, so it decides to invoke Dolphin via kioexec. Not sure why, it probably shouldn't do that

I can reproduce the error by running "~/kde/usr/lib64/libexec/kf5/kioexec ~/kde/usr/bin/dolphin mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//"

Internally kioexec fails while copying the URL to a temp location. I can reproduce that with "kioclient cp mtp:udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2// ."

Adding a slash between mtp: and udi= makes the error go away

It looks like https://invent.kde.org/network/kio-extras/-/merge_requests/146 was supposed to fix that kind of thing, but perhaps that fix was incomplete
Comment 14 Bug Janitor Service 2022-08-06 00:38:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kio-extras/-/merge_requests/182
Comment 15 Nicolas Fella 2022-08-06 00:41:37 UTC
Actually what I was seeing was just the (confusing) error message when copying with a URL that has a wrong udi. I'm still not quite sure what triggered the exact error in your case
Comment 16 Natalie Clarius 2022-08-06 02:13:44 UTC
I have kio-extras built and start Dolphin with the prefix file, still getting the error, so probably I have something misconfigured. If the issue is only with my setup, I can live with opening the phone from Dolphin instead.

Running "~/kde/usr/lib/libexec/kf5/kioexec ~/kde/usr/bin/dolphin mtp:/udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//" (with the slash) just gives me an error dialog

> Could not read file

with terminal output

> command= "/home/natalie/kde/usr/bin/dolphin" args= ("/home/natalie/kde/usr/bin/dolphin", "mtp:/udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//")
> kf.kio.core: Protocol Class of url QUrl("mtp:/udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//") , isn't ':local', cancelling job.
> Copying QUrl("mtp:/udi=/org/kde/solid/udev/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2//")  to QUrl("file:///home/natalie/.cache/kioexec/krun/335497_0/unnamed")
> All files downloaded, will call slotRunApp shortly
> No files downloaded -> exiting
> kf.notifications: Playing audio notification failed: Destroyed

Not sure how helpful this is.
Comment 17 Nicolas Fella 2022-08-06 15:25:51 UTC
Git commit befb9170bd8e565f52b7631f3c9d83581961f8af by Nicolas Fella.
Committed on 06/08/2022 at 15:15.
Pushed by nicolasfella into branch 'master'.

[mtp] Improve error when trying to copy from/to a nonexistant mtp device

If the device udi is not found we are currently throwing ERR_MALFORMED_URL, which is quite confusing because the URL is syntactically perfectly valid

Instead use ERR_DOES_NOT_EXIST like we do for the other functions in that case

M  +7    -3    mtp/kio_mtp.cpp

https://invent.kde.org/network/kio-extras/commit/befb9170bd8e565f52b7631f3c9d83581961f8af