Skip to content

Fix Gitlab::AuthLogger constant resolution

Fabio Pitino requested to merge fix-auth-logger-constant-resolution into master

What does this MR do and why?

When trying Packwerk on GitLab codebase as part of PoC'ing extracting components out of the monolith, I noticed that Packwerk was crashing with this error:

/Users/fabiopitino/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/packwerk-2.2.0/lib/packwerk/constant_discovery.rb:64:in `rescue in context_for': Ambiguous constant definition: (ConstantResolver::Error)

"Gitlab::AuthLogger" could refer to any of
  lib/gitlab/auth_logger.rb
  ee/lib/gitlab/auth_logger.rb

This is caused by the Gitlab::AuthLogger constant that is defined in both Core and EE. The problem is that the EE extension should be a module instead of overriding the constant.

This MR fixes the constant resolution.

Screenshots or screen recordings

$ FOSS_ONLY=1 rails c

[1] pry(main)> Gitlab::AuthLogger.file_name_noext
=> "auth"
$ rails c

[1] pry(main)> Gitlab::AuthLogger.file_name_noext
=> "auth_json"

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Fabio Pitino

Merge request reports

Loading