Harbor integration cannot list untagged artifacts: undefined method `map' for nil:NilClass

Summary

If an artifact in Harbor is not tagged, Gitlab will display an integration error message and the list of tags will not be shown.
With Harbor integration set up, this error occurs when there is no tag attached to the artifact in Harbor.

Steps to reproduce

  1. Setup integration with Harbor
  2. Push any tagged image to Harbor project registry
  3. Push same tagged image but with different SHA
  4. Remove tag from any of artifacts in Harbor project

harbor

What is the current bug behavior?

gitlab

What is the expected correct behavior?

List of tagged artifacts.

Relevant logs and/or screenshots

The following error is shown in production_json.log:

{
 "method": "GET",
 "path": "/mygroup/myproject/-/harbor/repositories/myproject/artifacts.json",
 "format": "json",
 "controller": "Projects::Harbor::ArtifactsController",
 "action": "index",
 "status": 500,
 ...
 "meta.caller_id": "Projects::Harbor::ArtifactsController#index",
 "meta.feature_category": "integrations",
 ...
 "exception.class": "NoMethodError",
 "exception.message": "undefined method `map' for nil:NilClass",
 "exception.backtrace": [
   "app/serializers/integrations/harbor_serializers/artifact_entity.rb:25:in `block in <class:ArtifactEntity>'",
   "grape-entity (1.0.1) lib/grape_entity/entity.rb:518:in `instance_exec'",
   "grape-entity (1.0.1) lib/grape_entity/entity.rb:518:in `exec_with_object'",
   "grape-entity (1.0.1) lib/grape_entity/exposure/block_exposure.rb:10:in `value'",
   "grape-entity (1.0.1) lib/grape_entity/exposure/base.rb:91:in `valid_value'",
   "grape-entity (1.0.1) lib/grape_entity/exposure/base.rb:73:in `serializable_value'",
   "grape-entity (1.0.1) lib/grape_entity/exposure/nesting_exposure.rb:41:in `block in serializable_value'",
   ...

Results of GitLab environment info

Expand for output related to GitLab environment info
System information System:		Debian 11 Current User:	git Using RVM:	no Ruby Version:	3.1.4p223 Gem Version:	3.4.22 Bundler Version:2.5.4 Rake Version:	13.0.6 Redis Version:	7.0.14 Sidekiq Version:7.1.6 Go Version:	unknown  GitLab information Version:	16.8.0 Revision:	16896fceb7a Directory:	/opt/gitlab/embedded/service/gitlab-rails DB Adapter:	PostgreSQL DB Version:	13.12 URL:		https://gitlab.company.local HTTP Clone URL:	https://gitlab.company.local/some-group/some-project.git SSH Clone URL:	git@gitlab.company.local:some-group/some-project.git Using LDAP:	no Using Omniauth:	yes Omniauth Providers: openid_connect  GitLab Shell Version:	14.32.0 Repository storages: - default: 	unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell  Gitaly - default Address: 	unix:/var/opt/gitlab/gitaly/gitaly.socket - default Version: 	16.8.0 - default Git Version: 	2.42.0 

Additional details & possible fixes

Edited by 🤖 GitLab Bot 🤖