Issues with post-receive hook

For new installation of 8.16.2, post-receive hooks are not working and so mail notifications and activities logs are not showing on dashboard. This is the error we are getting while push to the repo

remote: /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_post_receive.rb:58:in []': no implicit conversion of String into Integer (TypeError) remote: from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_post_receive.rb:58:in print_merge_request_link’
remote: from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_post_receive.rb:54:in block in print_merge_request_links' remote: from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_post_receive.rb:54:in each’
remote: from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_post_receive.rb:54:in print_merge_request_links' remote: from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_post_receive.rb:37:in exec’
remote: from hooks/post-receive:17:in `’
remote:

This is the post-receive hook file

#!/opt/gitlab/embedded/bin/ruby

Fix the PATH so that gitlab-shell can find git-upload-pack and friends.

ENV[‘PATH’] = ‘/opt/gitlab/bin:/opt/gitlab/embedded/bin:’ + ENV[‘PATH’]

#!/usr/bin/env ruby

This file was placed here by GitLab. It makes sure that your pushed commits

will be processed properly.

refs = $stdin.read
key_id = ENV.delete(‘GL_ID’)
repo_path = Dir.pwd

require_relative ‘…/lib/gitlab_custom_hook’
require_relative ‘…/lib/gitlab_post_receive’

if GitlabPostReceive.new(repo_path, key_id, refs).exec &&
GitlabCustomHook.new(repo_path, key_id).post_receive(refs)
exit 0
else
exit 1
end