Bug 480063 - Bad Request after add google drive account (Plasma 6.1Dev in Neon)
Summary: Bad Request after add google drive account (Plasma 6.1Dev in Neon)
Status: RESOLVED FIXED
Alias: None
Product: libkgapi
Classification: Frameworks and Libraries
Component: drive (other bugs)
Version First Reported In: unspecified
Platform: Neon Linux
: VHI major
Target Milestone: ---
Assignee: Daniel Vrátil
URL:
Keywords: qt6
: 411425 479470 481637 481887 486238 486384 487478 490089 493887 494339 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-01-19 20:38 UTC by Gilberto Ferreira
Modified: 2024-10-09 23:34 UTC (History)
16 users (show)

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


Attachments
bad-request (12.77 KB, image/png)
2024-01-19 20:38 UTC, Gilberto Ferreira
Details
dolphin kf.kio.workers.gdrive log (12.85 KB, text/x-log)
2024-09-24 06:01 UTC, alex
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gilberto Ferreira 2024-01-19 20:38:20 UTC
Created attachment 165050 [details]
bad-request

SUMMARY
Using Neon Unstable with Plasma 6.1 dev
After set google account and tried to browse gdrive with dolphin, I got 'Bad Request' error and nothing shows up.


STEPS TO REPRODUCE
1. Install kio-gdrive kaccounts6-integration kaccounts-providers
2. Set up the google account
3. Tried to browse the gdrive into dolphin give me bad request errors

OBSERVED RESULT
 bad request error

EXPECTED RESULT
access to gdrive folders and file via dolphin

SOFTWARE/OS VERSIONS
Operating System: KDE neon Unstable Edition
KDE Plasma Version: 6.0.80
KDE Frameworks Version: 5.249.0
Qt Version: 6.6.1
Kernel Version: 6.7.0-x64v4-xanmod1 (64-bit)
Graphics Platform: Wayland
Processors: 4 × AMD A12-9720P RADEON R7, 12 COMPUTE CORES 4C+8G
Memory: 15.1 GiB of RAM
Graphics Processor: AMD Radeon R7 Graphics
Manufacturer: Acer
Product Name: Aspire A515-41G
System Version: V1.09
Comment 1 megteheted_tohotom 2024-03-26 08:41:14 UTC
I can confirm this.

Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.2
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.5.0-26-generic (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i5-10210U CPU @ 1.60GHz
Memory: 15,4 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Manufacturer: LENOVO
System Version: ThinkPad E15
Comment 2 Jingglang 2024-03-26 15:37:49 UTC
I can confirm this. I run Dolphin from console and got this error:

```
org.kde.kgapi: Bad request, Google replied

{
  "error": {
    "code": 400,
    "message": "Invalid field selection etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)",
    "errors": [
      {
        "message": "Invalid field selection etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)",
        "domain": "global",
        "reason": "invalidParameter",
        "location": "fields",
        "locationType": "parameter"
      }
    ]
  }
}
```
Comment 3 Jacopo Torrini 2024-05-08 15:57:00 UTC
I can confirm the bug

Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.1.0
Qt Version: 6.7.0
Kernel Version: 6.5.0-28-lowlatency (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8550U CPU @ 1.80GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
Manufacturer: Dell Inc.
Product Name: Inspiron 5579
Comment 4 kamiszczu 2024-06-19 18:57:14 UTC
I can confirm the bug.
Operating System: KDE neon 6.0
KDE Plasma Version: 6.1.0
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.0
Kernel Version: 6.5.0-41-generic (64-bit)
Graphics Platform: Wayland
Comment 5 Tom F 2024-07-24 21:56:26 UTC
Error is also present in the User Edition:

KDE Plasma Version 6.1.3
KDE Frameworks Version 6.4.0
QT Version 6.7
Comment 6 Elvis Angelaccio 2024-09-23 20:45:11 UTC
If anyone can still reproduce this, please provide the output of:

    QT_LOGGING_RULES="kf.kio.workers.gdrive=true" dolphin
Comment 7 alex 2024-09-24 06:01:55 UTC
Created attachment 174015 [details]
dolphin kf.kio.workers.gdrive log

(In reply to Elvis Angelaccio from comment #6)
> If anyone can still reproduce this, please provide the output of:
> 
>     QT_LOGGING_RULES="kf.kio.workers.gdrive=true" dolphin

Here is the log from last KDE Neon dev ISO - neon-developer-20240729-1603.iso
Comment 8 Elvis Angelaccio 2024-09-24 21:31:14 UTC
(In reply to alex from comment #7)
> Created attachment 174015 [details]
> dolphin kf.kio.workers.gdrive log
> 
> (In reply to Elvis Angelaccio from comment #6)
> > If anyone can still reproduce this, please provide the output of:
> > 
> >     QT_LOGGING_RULES="kf.kio.workers.gdrive=true" dolphin
> 
> Here is the log from last KDE Neon dev ISO - neon-developer-20240729-1603.iso

Thanks! It'd help if you can also share the output of:

    QT_LOGGING_RULES="kf.kio.workers.gdrive=true;org.kde.kgapi=true" dolphin
Comment 9 Jacopo Torrini 2024-09-25 09:05:31 UTC
(In reply to Elvis Angelaccio from comment #8)
> (In reply to alex from comment #7)
> > Created attachment 174015 [details]
> > dolphin kf.kio.workers.gdrive log
> > 
> > (In reply to Elvis Angelaccio from comment #6)
> > > If anyone can still reproduce this, please provide the output of:
> > > 
> > >     QT_LOGGING_RULES="kf.kio.workers.gdrive=true" dolphin
> > 
> > Here is the log from last KDE Neon dev ISO - neon-developer-20240729-1603.iso
> 
> Thanks! It'd help if you can also share the output of:
> 
>     QT_LOGGING_RULES="kf.kio.workers.gdrive=true;org.kde.kgapi=true" dolphin

I have the same problem, so this is the output.

kf.kio.core.connection: Socket not connected QLocalSocket::PeerClosedError
kf.kio.core: An error occurred during write. The worker terminates now.
kf.kio.core: Connection::send() called with connection not inited
kf.kio.core: An error occurred during write. The worker terminates now.
kf.kio.workers.gdrive: Found google-provided account: "jactor@gmail.com"
kf.kio.workers.gdrive: "jactor@gmail.com" supports gdrive!
kf.kio.workers.gdrive: Got account credentials for: "jactor@gmail.com" , accessToken: "ya29.a0AcM612z5e4vKdAhQUo-KpE-..." , refreshToken: "1//09OI12aRWzl37CgYIARAAGAkSNw..."
kf.kio.workers.gdrive: KIO GDrive ready: version 24.08.1
kf.kio.core.connection: Socket not connected QLocalSocket::PeerClosedError
kf.kio.core: An error occurred during write. The worker terminates now.
kf.kio.workers.gdrive: Going to list QUrl("gdrive:/")
kf.kio.workers.gdrive: fileSystemFreeSpace is not supported for gdrive root url
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing new-account path
kf.kio.core: Connection::send() called with connection not inited
kf.kio.core: An error occurred during write. The worker terminates now.
kf.kio.workers.gdrive: stat()ing new-account path
kf.kio.workers.gdrive: stat()ing new-account path
kf.kio.workers.gdrive: stat()ing new-account path
kf.kio.workers.gdrive: stat()ing new-account path
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing new-account path
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: Going to list QUrl("gdrive:/jactor@gmail.com")
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffd431e16a0) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true&fields=kind,canCreateDrives&prettyPrint=false")
org.kde.kgapi: Status code:  200
kf.kio.workers.gdrive: Account "jactor@gmail.com" can't create Shared Drives
kf.kio.workers.gdrive: Getting root ID for "jactor@gmail.com"
kf.kio.workers.gdrive: Running job KGAPI2::Drive::AboutFetchJob(0x7ffd431e16a0) with accessToken "ya29.a0AcM612z5e4vKdAhQUo-KpE-..."
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffd431e16a0) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true&fields=kind,rootFolderId&prettyPrint=false")
org.kde.kgapi: Status code:  200
kf.kio.workers.gdrive: Completed job KGAPI2::Drive::AboutFetchJob(0x7ffd431e16a0) error code: 0 - message: ""
kf.kio.workers.gdrive: Running job KGAPI2::Drive::FileFetchJob(0x7ffd431e1940) with accessToken "ya29.a0AcM612z5e4vKdAhQUo-KpE-..."
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/files?q=((trashed %3D false) and ('0AIIlefvjVpyjUk9PVA' in parents))&includeItemsFromAllDrives=true&supportsAllDrives=true")
org.kde.kgapi: KGAPI2::Drive::FileFetchJob(0x7ffd431e1940) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/files?q=((trashed %3D false) and ('0AIIlefvjVpyjUk9PVA' in parents))&includeItemsFromAllDrives=true&supportsAllDrives=true")
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/files?q=((trashed %3D false) and ('0AIIlefvjVpyjUk9PVA' in parents))&includeItemsFromAllDrives=true&supportsAllDrives=true&fields=etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)&prettyPrint=false")
org.kde.kgapi: Status code:  400
org.kde.kgapi: Bad request, Google replied ' "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Invalid field selection etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)\",\n    \"errors\": [\n      {\n        \"message\": \"Invalid field selection etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)\",\n        \"domain\": \"global\",\n        \"reason\": \"invalidParameter\",\n        \"location\": \"fields\",\n        \"locationType\": \"parameter\"\n      }\n    ]\n  }\n}\n" '
kf.kio.workers.gdrive: Completed job KGAPI2::Drive::FileFetchJob(0x7ffd431e1940) error code: 400 - message: "Richiesta errata."
kf.kio.core: UDSEntry for '.' not found, creating a default one. Please fix the "kioworker" KIO worker.
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: Getting fileSystemFreeSpace for QUrl("gdrive:/jactor@gmail.com")
kf.kio.workers.gdrive: Running job KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) with accessToken "ya29.a0AcM612z5e4vKdAhQUo-KpE-..."
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true&fields=kind,quotaBytesTotal,quotaBytesUsedAggregate&prettyPrint=false")
org.kde.kgapi: Status code:  200
kf.kio.workers.gdrive: Completed job KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) error code: 0 - message: ""
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: stat()ing account root
kf.kio.workers.gdrive: Getting fileSystemFreeSpace for QUrl("gdrive:/jactor@gmail.com")
kf.kio.workers.gdrive: Running job KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) with accessToken "ya29.a0AcM612z5e4vKdAhQUo-KpE-..."
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true&fields=kind,quotaBytesTotal,quotaBytesUsedAggregate&prettyPrint=false")
org.kde.kgapi: Status code:  200
kf.kio.workers.gdrive: Completed job KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) error code: 0 - message: ""
kf.kio.workers.gdrive: Getting fileSystemFreeSpace for QUrl("gdrive:/jactor@gmail.com")
kf.kio.workers.gdrive: Running job KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) with accessToken "ya29.a0AcM612z5e4vKdAhQUo-KpE-..."
org.kde.kgapi: Queued QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) Dispatching request to QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true")
org.kde.kgapi: Received reply from QUrl("https://www.googleapis.com/drive/v2/about?includeSubscribed=true&fields=kind,quotaBytesTotal,quotaBytesUsedAggregate&prettyPrint=false")
org.kde.kgapi: Status code:  200
kf.kio.workers.gdrive: Completed job KGAPI2::Drive::AboutFetchJob(0x7ffd431e1970) error code: 0 - message: ""
Comment 10 Bug Janitor Service 2024-09-26 20:40:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/pim/libkgapi/-/merge_requests/49
Comment 11 Elvis Angelaccio 2024-09-26 20:51:07 UTC
(In reply to Bug Janitor Service from comment #10)
> A possibly relevant merge request was started @
> https://invent.kde.org/pim/libkgapi/-/merge_requests/49

Ok, I *think* I know what's going on and I have pushed a tentative fix in this MR.

Unfortunately I'm not able not reproduce the bug, so I'd appreciate if someone in this report can test this patch in libkgapi.
Comment 12 alex 2024-09-26 21:43:57 UTC
> Unfortunately I'm not able not reproduce the bug, so I'd appreciate if
> someone in this report can test this patch in libkgapi.

I just compile package kpim6-libkgapi-24.08.1-0zneon+22.04+jammy+release+build2 with your patch and now my google drive works without errors!
Thanks for the work!
Comment 13 Elvis Angelaccio 2024-09-27 15:55:38 UTC
(In reply to alex from comment #12)
> > Unfortunately I'm not able not reproduce the bug, so I'd appreciate if
> > someone in this report can test this patch in libkgapi.
> 
> I just compile package
> kpim6-libkgapi-24.08.1-0zneon+22.04+jammy+release+build2 with your patch and
> now my google drive works without errors!
> Thanks for the work!

That's great, thanks for testing!
Comment 14 Elvis Angelaccio 2024-09-30 19:34:24 UTC
*** Bug 493887 has been marked as a duplicate of this bug. ***
Comment 15 Elvis Angelaccio 2024-10-03 16:56:45 UTC
Git commit b57168b19e9ea0573a721e30c4abea2d390239d2 by Elvis Angelaccio.
Committed on 26/09/2024 at 20:47.
Pushed by elvisangelaccio into branch 'release/24.08'.

FileFetchJob: fix static initialization order problem

BasicFields/AccessFields/SharingFields are declared as static members,
but in their definitions they require other static members.

This is a classic static initialization order problem. In particular it
may happen that when BasicFields is defined, the
Id/Title/.../Permissions members have _not_ been defined yet: BasicFields
then becomes a QStringList containing 8 empty QStrings.

This is likely what causes bug #480063 where the following broken query
string is sent to google (by a FileFetchJob triggered by kio-gdrive):

    fields=etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)

This commit fixes the problem by duplicating the string literals in the
definitions of BasicFields/AccessFields/SharingFields.

This commit is only meant for the relase/24.08 branch, so that we don't
need to do breaking changes in the API.

On master we should do the right thing, which is to break the API and
change BasicFields/AccessFields/SharingFields from static class members
to static class methods.
FIXED-IN: 24.08.2

M  +22   -22   src/drive/filefetchjob.cpp

https://invent.kde.org/pim/libkgapi/-/commit/b57168b19e9ea0573a721e30c4abea2d390239d2
Comment 16 Bug Janitor Service 2024-10-03 17:18:49 UTC
A possibly relevant merge request was started @ https://invent.kde.org/pim/libkgapi/-/merge_requests/50
Comment 17 Elvis Angelaccio 2024-10-09 21:11:11 UTC
*** Bug 494339 has been marked as a duplicate of this bug. ***
Comment 18 Elvis Angelaccio 2024-10-09 21:30:54 UTC
Git commit 6305de6caf85e1ed33448820b0a3dc14b61a60b0 by Elvis Angelaccio.
Committed on 03/10/2024 at 17:06.
Pushed by elvisangelaccio into branch 'master'.

FileFetchJob: fix static initialization order problem

BasicFields/AccessFields/SharingFields are declared as static members,
but in their definitions they require other static members.

This is a classic static initialization order problem. In particular it
may happen that when BasicFields is defined, the
Id/Title/.../Permissions members have _not_ been defined yet: BasicFields
then becomes a QStringList containing 8 empty QStrings.

This is what caused bug #480063 where the following broken query
string was sent to google (by a FileFetchJob triggered by kio-gdrive):

    fields=etag,kind,nextLink,nextPageToken,selfLink,items(,,,,,,,,labels,exportLinks,lastViewedByMeDate,alternateLink,kind)

The bug has been fixed with commit b57168b19e in the 24.08 release branch.

This commit adapts the fix for the master branch, where we can drop the
duplicated strings and just break the public API: this should be a
problem because kio-gdrive should be the only-user and has the same
release schedule as libkgapi.

M  +34   -22   src/drive/filefetchjob.cpp
M  +12   -3    src/drive/filefetchjob.h

https://invent.kde.org/pim/libkgapi/-/commit/6305de6caf85e1ed33448820b0a3dc14b61a60b0
Comment 19 Bug Janitor Service 2024-10-09 21:34:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kio-gdrive/-/merge_requests/39
Comment 20 Elvis Angelaccio 2024-10-09 21:35:29 UTC
Git commit b3efca3d7484b374bb718cc75326956e62ab1ade by Elvis Angelaccio.
Committed on 09/10/2024 at 21:32.
Pushed by elvisangelaccio into branch 'master'.

Adapt to libkgapi breaking change

See commit 6305de6caf85e1ed33448820b0a3dc14b61a60b0 in libkgapi.

M  +2    -1    CMakeLists.txt
M  +1    -1    src/kio_gdrive.cpp

https://invent.kde.org/network/kio-gdrive/-/commit/b3efca3d7484b374bb718cc75326956e62ab1ade
Comment 21 Elvis Angelaccio 2024-10-09 21:45:38 UTC
*** Bug 490089 has been marked as a duplicate of this bug. ***
Comment 22 Elvis Angelaccio 2024-10-09 21:47:24 UTC
*** Bug 486238 has been marked as a duplicate of this bug. ***
Comment 23 Elvis Angelaccio 2024-10-09 22:11:50 UTC
*** Bug 411425 has been marked as a duplicate of this bug. ***
Comment 24 Elvis Angelaccio 2024-10-09 22:14:00 UTC
*** Bug 481637 has been marked as a duplicate of this bug. ***
Comment 25 Elvis Angelaccio 2024-10-09 22:15:32 UTC
*** Bug 487478 has been marked as a duplicate of this bug. ***
Comment 26 Elvis Angelaccio 2024-10-09 22:15:53 UTC
*** Bug 486384 has been marked as a duplicate of this bug. ***
Comment 27 Elvis Angelaccio 2024-10-09 22:17:22 UTC
*** Bug 481887 has been marked as a duplicate of this bug. ***
Comment 28 Elvis Angelaccio 2024-10-09 22:18:30 UTC
*** Bug 479470 has been marked as a duplicate of this bug. ***