Importing a content to Satellite raises "This field must be unique." error with 400 error code
Environment
Red Hat Satellite 6
Issue
A content import to disconnected Satellite failed in past. Trying to import again, we get HTTP status code: 400 error with response body "This field must be unique.".
Resolution
This is still a bug in Satellite 6.12 and later versions, and it is being tracked under Red Hat Jira This content is not included.SAT-31862.
For a permanent fix:
Upgrade to Sat 6.10.4 (or higher) where the This content is not included.underlying bugzilla is fixed.
For a workaround(Satellite 6.12 and above):
-
Ensure no import tasks are running.
-
Define right PULP_CERTS for Satellite version:
-
For Satellite < 6.13:
PULP_CERTS="--cert /etc/pki/katello/certs/pulp-client.crt --key /etc/pki/katello/private/pulp-client.key" -
For Satellite >= 6.13:
PULP_CERTS="--cert /etc/foreman/client_cert.pem --key /etc/foreman/client_key.pem"
- Check if there are indeed importers left behind:
# curl $PULP_CERTS https://$(hostname -f)//pulp/api/v3/importers/core/pulp/|json_reformat
- Delete all importers:
PULP_HREFS=$(curl $PULP_CERTS https://$(hostname -f)//pulp/api/v3/importers/core/pulp/|json_reformat |grep pulp_href|cut -d ':' -f 2|tr -d '",')
for pulp_href in $PULP_HREFS; do curl -X DELETE $PULP_CERTS https://$(hostname -f)$pulp_href; done
- Start the import again.
For more KB articles/solutions related to Red Hat Satellite 6.x Content View Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Content View Issues
Root Cause
There was a pending pulp importer of the same name, as an orphaned artefact forgotten from the previous unsuccessful import attempt.
Diagnostic Steps
Foreman task fails with error like:
Error message: the server returns an error
HTTP status code: 400
Response headers: {"Date"=>"Tue, 05 Apr 2022 05:40:18 GMT", "Server"=>"gunicorn", "Content-Type"=>"application/json", "Vary"=>"Accept,Cookie", "Allow"=>"GET, POST, HEAD, OPTIONS", "X-Frame-Options"=>"SAMEORIGIN", "Content-Length"=>"39", "Correlation-ID"=>"3b89d205-b9e7-4ad1-a514-ad1fab220df7", "Access-Control-Expose-Headers"=>"Correlation-ID", "Via"=>"1.1 satellite.example.com", "Connection"=>"close"}
Response body: {"name":["This field must be unique."]}
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.