`NoMethodError: undefined method 'session' for #<#<Class:0x00007fa18c446120>:0x00007fa164c84a08>` for API calls to `groups/:group_id/audit_events`
Sentry Issue: STAGINGGITLABCOM-NYB
NoMethodError: undefined method `session' for #<#<Class:0x00007fa18c446120>:0x00007fa164c84a08>
grape-path-helpers/named_route_matcher.rb:7:in `method_missing'
return super unless method_id.to_s =~ /_path$/
api/unique_call_tracking.rb:6:in `visitor_id'
return context.session[:visitor_id] if context.session[:visitor_id].present?
api/unique_call_tracking.rb:16:in `track_redis_hll_event'
return unless visitor_id
api/unique_call_tracking.rb:22:in `after'
track_redis_hll_event(@options[:event_name], @options[:feature])
grape/middleware/base.rb:38:in `call!'
after_response = after
...
(125 additional frame(s) were not displayed)
NoMethodError: undefined method `session' for #<#<Class:0x00007fa18c446120>:0x00007fa164c84a08>
How to reproduce
https://staging.gitlab.com/api/v4/groups/2132458/audit_events
That group is public.
QA Failure Summary
https://ops.gitlab.net/gitlab-org/quality/staging/-/jobs/1732420
Failures in four tests:
-
./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb[1:1:2:1:1]
# Manage Group Change repository size limit behaves like audit event logs audit events for UI operations -
./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb[1:1:5:1:1]
# Manage Group Add and remove project access behaves like audit event logs audit events for UI operations -
./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb[1:1:4:1:1]
# Manage Group Add user, change access level, remove user behaves like audit event logs audit events for UI operations -
./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb[1:1:3:1:1]
# Manage Group Update group name behaves like audit event logs audit events for UI operations
Stack trace
Similar failures for each test. For example:
1) Manage Group Change repository size limit behaves like audit event logs audit events for UI operations
Failure/Error:
Support::Retrier.retry_until(max_duration: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME, sleep_interval: 1) do
get_audit_event_count(group) >= new_event_count
end
QA::Support::Repeater::WaitExceededError:
Wait condition not met after 60 seconds
Shared Example Group: "audit event" called from ./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb:70
# ./qa/support/repeater.rb:44:in `repeat_until'
# ./qa/support/retrier.rb:48:in `retry_until'
# ./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb:142:in `wait_for_audit_events'
# ./qa/specs/features/ee/browser_ui/1_manage/group/group_audit_logs_1_spec.rb:12:in `block (3 levels) in <module:QA>'
Screenshot / HTML page
The failure happens during an API call but the screenshots seem to show the audited event was completed successfully. Not sure if they're helpful but here they are:
Expand for screenshots
manage_group_change_repository_size_limit_behaves_like_audit_event_logs_audit_events_for_ui_operatio.htmlmanage_group_update_group_name_behaves_like_audit_event_logs_audit_events_for_ui_operations.html
Possible fixes
Looks like the same failures reported in the discussions in #197972 (closed)
Not sure about a fix, but it might be useful to leave in logging of the count of events if there's a failure.
But the fact that it just started to fail consistently suggests something changed...