Project

General

Profile

Actions

Bug #34966

closed

undefined method `find' for nil:NilClass when importing content that has gpg_keys associated to it

Added by Joniel Pasqualetto over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Inter Server Sync
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

Description of problem:

Fail to parse the the metadata when importing products/repositories that have a GPG key associated. Import task fails almost immediately with the following trace back:

~~
2022-05-25T10:22:02 [E|app|0a12262c] NoMethodError: undefined method `find' for nil:NilClass
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/services/katello/pulp3/content_view_version/metadata_map.rb:108:in `gpg_key_for_product'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/services/katello/pulp3/content_view_version/metadata_map.rb:63:in `block in parse_products'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/services/katello/pulp3/content_view_version/metadata_map.rb:57:in `map'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/services/katello/pulp3/content_view_version/metadata_map.rb:57:in `parse_products'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/services/katello/pulp3/content_view_version/metadata_map.rb:27:in `initialize'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/lib/actions/katello/content_view_version/import.rb:6:in `new'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/lib/actions/katello/content_view_version/import.rb:6:in `plan'
0a12262c | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.9/lib/dynflow/action.rb:515:in `block (3 levels) in execute_plan'
~~

Version-Release number of selected component (if applicable):
Satellite 6.10.5 (katello-4.1.1.56)

How reproducible:
Always

Steps to Reproduce:
1. Create a custom product/repository and assign a GPG key to it
2. Create a CV including the repository created on step 1
3. Create a complete export of the CV created on step 2
4. Try importing the content

Actual results:

Fail to process the metadata and import doesn't work:

~~~
  1. hammer content-import version --path /var/lib/pulp/imports/Zabbix/1.0/2022-05-25T11-20-12-04-00/ --organization-id 4
    Could not import the archive.:
    undefined method `find' for nil:NilClass
    ~~~

Expected results:

Import to start

Additional info:

Issue happens here (file /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.56/app/services/katello/pulp3/content_view_version/metadata_map.rb):

~~
def initialize(metadata:)
@toc = metadata[:toc]
@products = parse_products(metadata[:products]) if metadata[:products]
@repositories = parse_repositories(metadata[:repositories]) if metadata[:repositories]
@content_view = parse_content_view(metadata[:content_view]) if metadata[:content_view]
@content_view_version = parse_content_view_version(metadata[:content_view_version]) if metadata[:content_view_version]
@from_content_view_version = parse_content_view_version(metadata[:from_content_view_version]) if metadata[:from_content_view_version]
@gpg_keys = parse_gpg_keys(metadata[:gpg_keys]) if metadata[:gpg_keys]
end
~~

When initializing the variable @products, the parser tries to access the variable @gpg_keys, that has not been initialized yet at that point. Simply changing the order of the initialization of those variables allows the import to happen.

Actions

Also available in: Atom PDF