pulp / pulp-cli

https://docs.pulpproject.org/pulp_cli/
GNU General Public License v2.0
36 stars 41 forks source link

repo-config option fails to parse #1065

Open simenon opened 1 month ago

simenon commented 1 month ago

Version "versions": { "deb": "3.3.1", "gem": "0.6.1", "rpm": "3.27.1", "core": "3.57.1", "file": "3.57.1", "maven": "0.8.1", "ostree": "2.4.3", "python": "3.12.1", "ansible": "0.22.1", "certguard": "3.57.1", "container": "2.21.0" }

Describe the bug pulp rpm repository create --name random --autopublish --repo-config '{"gpgcheck": 0, "repo-gpgcheck": 0}'

Error: Validation failed for 'repositories_rpm_rpm_create': application/json: 'repo_config' is expected to be a string. application/x-www-form-urlencoded: 'repo_config' is expected to be a string. multipart/form-data: 'repo_config' is expected to be a string.

same error goes for rpm publication

To Reproduce See Above

Expected behavior --repo-config should be parsed

Additional context based on example here https://pulpproject.org/pulp_rpm/docs/user/tutorials/create_sync_publish/?h=gpgcheck#create-a-publication-with-a-configrepo

pedro-psb commented 1 month ago

Can you run in verbose mode? I copy-pasted this and got no errors w/ similar version-set.

 pulp -vvv rpm repository create --name random --autopublish --repo-config '{"gpgcheck": 0, "repo-gpgcheck": 0}'
simenon commented 4 weeks ago

I am not sure why it is failing, but on a system with RH8.10 it worked before. Then i updated to the latest pulp pod image and somewhere after that it started failing. On a similar test system with RH9.4 it works with no problems. I tried it on another machine with 8.10 and it works.

this seems a problem specific to one machine.

pulp -vvv rpm repository create --name random --autopublish --repo-config '{"gpgcheck": 0, "repo-gpgcheck": 0}'
Error: Validation failed for 'repositories_rpm_rpm_create':
  application/json: 'repo_config' is expected to be a string.
  application/x-www-form-urlencoded: 'repo_config' is expected to be a string.
  multipart/form-data: 'repo_config' is expected to be a string.
python --version
Python 3.6.8
pulp --version
pulp3 command line interface, version 0.23.2
pip list
Package             Version
------------------- --------
certifi             2024.6.2
charset-normalizer  2.0.12
click               8.0.4
click-shell         2.1
defusedxml          0.7.1
dynaconf            3.1.5
httpie              2.6.0
idna                3.7
importlib-metadata  4.8.3
importlib-resources 5.4.0
jq                  1.7.0
packaging           21.3
pip                 21.3.1
PuLP                2.7.0
pulp-cli            0.23.2
pulp-glue           0.23.2
Pygments            2.14.0
pyparsing           3.1.2
PySocks             1.7.1
PyYAML              6.0.1
requests            2.27.1
requests-toolbelt   1.0.0
schema              0.7.7
setuptools          39.2.0
toml                0.10.2
typing_extensions   4.1.1
urllib3             1.26.19
zipp                3.6.0
simenon commented 4 weeks ago

I suspect this is a python3.6 issue

Given that i create a venv for python3.6 as follows

# This does not work
python3 -m venv .venv/pulp36
source .venv/pulp36/bin/activate
pip install pulp-cli[pygments]
pulp -vvv rpm repository create --name random2 --autopublish --repo-config '{"gpgcheck": 0, "repo-gpgcheck": 0}'
Error: Validation failed for 'repositories_rpm_rpm_create':
  application/json: 'repo_config' is expected to be a string.
  application/x-www-form-urlencoded: 'repo_config' is expected to be a string.
  multipart/form-data: 'repo_config' is expected to be a string.
# This works
python3.9 -m venv .venv/pulp39
source .venv/pulp39/bin/activate
pip install pulp-cli[pygments]
pulp -vvv rpm repository create --name random2 --autopublish --repo-config '{"gpgcheck": 0, "repo-gpgcheck": 0}'
repositories_rpm_rpm_create : post http://localhost:8080/pulp/api/v3/repositories/rpm/rpm/
  User-Agent: Pulp-CLI/0.27.2
  Accept-Encoding: gzip, deflate
  Accept: application/json
  Connection: keep-alive
  Content-Length: 71
  Content-Type: application/json
  Authorization: Basic YWRtaW46NnJASDg0OjFeRy1ERDNmdjt8SDk=
b'{"name": "random2", "repo_config": {"gpgcheck": 0, "repo-gpgcheck": 0}}'
Response: 400
  Server: nginx/1.22.1
  Date: Wed, 21 Aug 2024 13:10:48 GMT
  Content-Type: application/json
  Content-Length: 39
  Connection: keep-alive
  Vary: Accept
  Allow: GET, POST, HEAD, OPTIONS
  X-Frame-Options: DENY
  X-Content-Type-Options: nosniff
  Referrer-Policy: same-origin
  Cross-Origin-Opener-Policy: same-origin
  Correlation-ID: 39cdc3c082064f59aa5c67793393bc4d
  Access-Control-Expose-Headers: Correlation-ID
{"name":["This field must be unique."]}
Error: {"name":["This field must be unique."]}
pedro-psb commented 4 weeks ago

That's odd. I couldn't reproduce with:

But since changing the client setup solves the issue, that should be moved to pulp-cli.