Project

Profile

Help

Issue #8941

closed

media_type list filter doesn't work with ruby bindings, expects array which api doesn't support

Added by jsherril@redhat.com over 3 years ago. Updated over 3 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Katello
Sprint:
Sprint 99
Quarter:

Description

After upgrading to the pulp_container ruby bindings, when calling the list content_manifests_api and passing media_type as a filter, we get an error:

NoMethodError: undefined method `all?' for "application/vnd.docker.distribution.manifest.v1+json":String

all? is typically called on an array, and looking at the code does show the bindings are expecting an array:

      allowable_values = ["application/vnd.docker.distribution.manifest.list.v2+json", "application/vnd.docker.distribution.manifest.v1+json", "application/vnd.docker.distribution.manifest.v2+json", "application/vnd.oci.image.index.v1+json", "application/vnd.oci.image.manifest.v1+json"]
      if @api_client.config.client_side_validation && opts[:'media_type'] && !opts[:'media_type'].all? { |item| allowable_values.include?(item) }
        fail ArgumentError, "invalid value for \"media_type\", must include one of #{allowable_values}"
      end

However if we try to pass an array, we get an error from the server

Response body: {"errors":["Invalid Filter: 'media_type[]'"]}
Actions #1

Updated by mdellweg over 3 years ago

From the api docs, i see:

cat api.json | jq '.paths."/pulp/api/v3/content/container/manifests/".get.parameters[]|select(.name=="media_type")'
{
  "in": "query",
  "name": "media_type",
  "schema": {
    "type": "array",
    "items": {
      "type": "string",
      "enum": [
        "application/vnd.docker.distribution.manifest.list.v2+json",
        "application/vnd.docker.distribution.manifest.v1+json",
        "application/vnd.docker.distribution.manifest.v2+json",
        "application/vnd.oci.image.index.v1+json",
        "application/vnd.oci.image.manifest.v1+json"
      ]
    }
  },
  "explode": true,
  "style": "form"
}

and this indeed asks for an array, so the bindings seem to be translated correctly.

However django_filter's MultipleChoiceFilter wants the params to just appear multiple times without the [] it seems: https://django-filter.readthedocs.io/en/stable/ref/filters.html#multiplechoicefilter

Actions #2

Updated by mdellweg over 3 years ago

Also the openapi standard specifies arrays in querystrings by repeating the keyword without []: https://swagger.io/docs/specification/describing-parameters/#query-parameters

So i start to think the bindings are not rendering arrays correctly.

Actions #3

Updated by dkliban@redhat.com over 3 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to dkliban@redhat.com
  • Sprint set to Sprint 99

Added by dkliban@redhat.com over 3 years ago

Revision b832d742 | View on GitHub

Add Ruby templates to expose the 'params_encoder' config from Faraday

I opened a PR upstream with the same changes: https://github.com/OpenAPITools/openapi-generator/pull/9839

fixes: #8941 https://pulp.plan.io/issues/8941

Actions #4

Updated by dkliban@redhat.com over 3 years ago

  • Status changed from ASSIGNED to MODIFIED
Actions #5

Updated by dkliban@redhat.com over 3 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE
  • Sprint/Milestone set to 2.7.1

Fixed when bindings were released with 2.7.1 release.

Also available in: Atom PDF