This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2278648 - Improve the API and Hammer error message when content export fails due to lack of permissions
Summary: Improve the API and Hammer error message when content export fails due to lac...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Inter Satellite Sync
Version: 6.14.3
Hardware: All
OS: All
unspecified
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-05-02 14:49 UTC by Sayan Das
Modified: 2024-06-06 17:36 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-06-06 17:36:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   SAT-24898 0 None Migrated None 2024-06-06 17:36:23 UTC

Description Sayan Das 2024-05-02 14:49:59 UTC
Description of problem:

The main problem is reported in https://bugzilla.redhat.com/show_bug.cgi?id=2278609 along with reproducer steps. 

Now, The hardest part was to identify why the error logged in production.log was 
~~~
2024-05-02T15:17:36 [E|bac|c3dadce9] Validation failed: Label has already been taken, Name has already been taken (ActiveRecord::RecordInvalid)
~~~

or hammer says this:
~~
Could not export the library:
  422 Unprocessable Entity
~~

When the issue was due to the lack of permissions to create a content view.


It's even worse when someone uses Ansible module redhat.satellite.content_export_library to do the content export 


PLAY [Reproducer for Thales] **********************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************************************
ok: [satellite614.lab.internal]

TASK [sat-export-library : Do a full export of the Library env] ***********************************************************************************************************************************************************************
fatal: [satellite614.lab.internal]: FAILED! => {"changed": false, "error": "Validation failed: Label has already been taken, Name has already been taken\n/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:80:in `raise_validation_error'\n/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:53:in `save!'\n/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:302:in `block in save!'\n/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'\n/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'\n/usr/share/gems/gems/activerecord-
...
huge traceback ....
...
with_force_shutdown'\n/usr/share/gems/gems/puma-6.3.1/lib/puma/request.rb:99:in `handle_request'\n/usr/share/gems/gems/puma-6.3.1/lib/puma/server.rb:443:in `process_client'\n/usr/share/gems/gems/puma-6.3.1/lib/puma/server.rb:245:in `block in run'\n/usr/share/gems/gems/puma-6.3.1/lib/puma/thread_pool.rb:151:in `block in spawn_thread'\n/usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'", 
..
"msg": "Error while performing library on content_exports: 422 Client Error: Unprocessable Content for url: https://satellite614.lab.internal/katello/api/content_exports/library"}

PLAY RECAP ****************************************************************************************************************************************************************************************************************************
satellite614.lab.internal  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   


Here we get to see two different error messages, one at the top of the traceback that says "Validation failed" and then another at the end, that says "Unprocessable Content for URL" but again none of them clearly says anything about any missing permissions at all.


If i run the API call directly, That would also result into something like that i.e. 

# curl -su sat_export:password@123 -X POST -H "Content-Type: application/json" https://`hostname -f`/katello/api/content_exports/library -d '{"organization_id": 1, "format": "syncable", "destination_server": "disconnected_sat"}' 
Validation failed: Label has already been taken, Name has already been taken

/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:80:in `raise_validation_error'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:53:in `save!'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:302:in `block in save!'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:302:in `save!'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/suppressor.rb:48:in `save!'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/persistence.rb:639:in `block in update!'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/persistence.rb:637:in `update!'
/usr/share/gems/gems/katello-4.9.0.23/app/lib/actions/pulp3/orchestration/content_view_version/export_library.rb:18:in `plan'
/usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:531:in `block (3 levels) in execute_plan'
/usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
/usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
/usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:36:in `plan'
/usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'


Now, even if we fix the "Content Exporter" role, We cannot stop end-users from creating a new role with their own set of permissions and they can miss adding one or two permissions there and then run into a similar problem on their own. And without a clear error message, There is no way to easily identify the root cause here.


Expected results:

A) When the root cause is, User X does not have Y permission to do something, Then the error should be printed like that instead of saying "Validation failed: Label has already been taken, Name has already been taken" because that is a complete misdirection. 

B) hammer should show the same error message as API and needs to make sense. 

This 
~~
Could not export the library:
  422 Unprocessable Entity
~~
is not something that says, some permissions are missing or the user X is unable to do Y.


Additional info:

NA

Comment 2 Eric Helms 2024-06-06 17:36:25 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.