openSUSE / osc

The Command Line Interface to work with an Open Build Service
http://openbuildservice.org/
GNU General Public License v2.0
170 stars 185 forks source link

Asking for maintainers of a package returns a 400 status code #984

Closed danidoni closed 2 years ago

danidoni commented 2 years ago

The documentation about osc maintainer says:

maintainer (bugowner): Show maintainers according to server side configuration

    # Search for official maintained sources in OBS instance
    osc maintainer BINARY_OR_PACKAGE_NAME <options>
    osc maintainer -U <user> <options>
    osc maintainer -G <group> <options>

    # Lookup via containers
    osc maintainer <options>
    osc maintainer PRJ <options>
    osc maintainer PRJ PKG <options>

So I can run osc maintainer ruby2.5 and get the maintainer. This actually raises a 400 Bad Request error as shown below, when using the -d --http-full-debug command options.

osc -d --http-full-debug maintainer ruby2.5

-- GET https://api.opensuse.org/search/owner?package=ruby2.5
GET https://api.opensuse.org/search/owner?package=ruby2.5
send: b'GET /search/owner?package=ruby2.5 HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: api.opensuse.org\r\nUser-agent: osc/0.174\r\nCookie: [REDACTED]\r\nConnection: close\r\n\r\n'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Fri, 10 Dec 2021 11:32:51 GMT
header: Server: Apache/2.4.43 (Linux/SUSE)
header: Strict-Transport-Security: max-age=31536000
header: cache-control: no-cache
header: vary: Accept,Accept-Encoding
header: referrer-policy: strict-origin-when-cross-origin
header: x-permitted-cross-domain-policies: none
header: x-xss-protection: 1; mode=block
header: x-opensuse-runtimes: {"view":1.6147780697792768,"db":2.5324649177491665,"backend":0}
header: x-request-id: df1ec8a5-044a-4d45-8ff8-33a24cb9d125
header: x-opensuse-apiversion: 2.11~alpha.20211207T151322.cfbe3fed31
header: x-download-options: noopen
header: x-runtime: 0.014127
header: x-frame-options: SAMEORIGIN
header: x-content-type-options: nosniff
header: x-opensuse-errorcode: no_binary
header: x-powered-by: Phusion Passenger(R) 6.0.8
header: status: 400 Bad Request
header: content-type: application/xml; charset=utf-8
header: Connection: close
header: Transfer-Encoding: chunked

-- GET https://api.opensuse.org/search/owner?binary=ruby2.5
GET https://api.opensuse.org/search/owner?binary=ruby2.5
send: b'GET /search/owner?binary=ruby2.5 HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: api.opensuse.org\r\nUser-agent: osc/0.174\r\nCookie: [REDACTED]\r\nConnection: close\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Fri, 10 Dec 2021 11:32:52 GMT
header: Server: Apache/2.4.43 (Linux/SUSE)
header: Strict-Transport-Security: max-age=31536000
header: cache-control: max-age=0, private, must-revalidate
header: vary: Accept,Accept-Encoding
header: referrer-policy: strict-origin-when-cross-origin
header: x-permitted-cross-domain-policies: none
header: x-xss-protection: 1; mode=block
header: x-opensuse-runtimes: {"view":2.2607280407100916,"db":43.87335269711912,"backend":45.453598}
header: x-request-id: 22da4917-5ae6-4828-8b5b-91a5af1d7d30
header: x-opensuse-apiversion: 2.11~alpha.20211207T151322.cfbe3fed31
header: x-download-options: noopen
header: x-frame-options: SAMEORIGIN
header: x-runtime: 0.231241
header: x-content-type-options: nosniff
header: x-powered-by: Phusion Passenger(R) 6.0.8
header: etag: W/"e38c057f9b62c2ffd13df9b3c56ab6a3"
header: status: 200 OK
header: content-type: application/xml; charset=utf-8
header: Connection: close
header: Transfer-Encoding: chunked
Defined in project:  SUSE:SLE-15:Update
  bugowner of ruby2.5 :
   -

  maintainer of ruby2.5 :
   jumper-bot, group:ibs-maintenance-team

Looking at the API documentation looks like OBS expects Either binary, user or group parameter is required. when issuing the first call.

Expected Result

No 400 Bad Request errors raised or osc asking me to provide the required parameters.

marcus-h commented 2 years ago

On 2021-12-10 03:41:08 -0800, Dani Donisa wrote:

> Looking at the [API documentation](https://build.opensuse.org/apidocs/index#149) looks like OBS expects `Either binary, user or group parameter is required.` when issuing the first call. > A project parameter also works. For instance, osc api '/search/owner?package=osc&project=openSUSE:Tools' > Expected Result > ============ > No 400 Bad Request errors raised or `osc` asking me to provide the required parameters. > osc issues a wrong api call - that's definitely something we should fix. But despite the wrong/useless api call, you get the "expected" results, right?
danidoni commented 2 years ago

osc issues a wrong api call - that's definitely something we should fix. But despite the wrong/useless api call, you get the "expected" results, right?

Yes, but we also get lots of 400 calls because some users use the osc maintainer call in scripts.

Do you know how to workaround the osc maintainer call so it doesn't raise those 400 errors?

dmach commented 2 years ago

osc issues a wrong api call - that's definitely something we should fix.

Given the fact that the first search always fails with 400 (bare ?package=<pkg> without &project=<prj> always does, right?), shouldn't we simply remove it from the code and search ?binary=<pkg> only? @marcus-h are you fine with this or did you have a different idea?

marcus-h commented 2 years ago

On 2022-01-03 15:35:19 +0000, Daniel Mach wrote:

osc issues a wrong api call - that's definitely something we should fix.

Given the fact that the first search always fails with 400 (bare ?package=<pkg> without &project=<prj> always does, right?), shouldn't we simply remove it from the code and search ?binary=<pkg> only? @marcus-h are you fine with this or did you have a different idea?

In principle yes but it might just be a "missing" feature in the API's owner controller/model because searching by "package" was the purpose of commit 36fc925ee062eeb7b23b09a29e69be0c4bae3f86 ("maintainer search: lookup via package name by default and binary as fallback").

@adrianschroeter: any idea?

(I'm fine with removing the call for the time being.)

adrianschroeter commented 2 years ago

The first one should be able to to find results by finding the package container in some cases. The default project(s) is defined via the OBS:OwnerRootProject attribute.

The reasoning behind is that some users expect that their binary rpms get found, others expect that the package container is found, even when no rpm with such name exists (source rpms do not count here).

So I think it is correct as it is atm.

marcus-h commented 2 years ago

On 2022-01-05 07:04:29 -0800, Adrian Schröter wrote:

The first one should be able to to find results by finding the package container in some cases. The default project(s) is defined via the OBS:OwnerRootProject attribute.

Hmm but that's currently not reflected in the API code (unless I miss something). owner_package_or_project directly returns nil if there is no project query parameter, which results in status 400.

adrianschroeter commented 2 years ago

That is a regression on the api side, should be fixed hopefully by this:

https://github.com/openSUSE/open-build-service/pull/12052

dmach commented 2 years ago

This seems to be fixed on the server as stated in the previous comment, closing.

(Please ignore a slightly different debug output, I'm running a test build that includes https://github.com/openSUSE/osc/pull/1000)

$ osc -d --http-debug maintainer ruby2.5
DEBUG: ----------------------------------------
DEBUG: GET https://api.opensuse.org/search/owner?package=ruby2.5
DEBUG: send: b'GET /search/owner?package=ruby2.5 HTTP/1.1\r\nHost: api.opensuse.org\r\nAccept-Encoding: identity\r\nuser-agent: osc/0.176.git\r\n\r\n'
DEBUG: reply: 'HTTP/1.1 200 OK\r\n'
...
Defined in project:  SUSE:SLE-15:Update
  bugowner of ruby2.5 : 
   -

  maintainer of ruby2.5 : 
   jumper-bot, group:ibs-maintenance-team