Alt_usage_data failing undefined method `values' for -1:Integer
Summary
We rescue to -1 while version-app is expecting a hash
Background https://sentry.gitlab.net/gitlab/versiongitlabcom/issues/1599648/
git: { version: alt_usage_data { Gitlab::Git.version } },
Gitlab::Git.version
falis and with alt_usage_data we have the outcome {git: {version: -1}}
while the version app is expecting a hash git_version: (params.dig(:git, :version) || {}).values.join('.'),
Steps to reproduce
(How one can reproduce the issue - this is very important)
What is the current bug behavior?
Breaks the usage ping payload parsing https://gitlab.com/gitlab-services/version-gitlab-com/-/blob/master/app/services/usage_ping/service_handler.rb#L77
What is the expected correct behavior?
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/usage_data.rb#L216
We have multiple cases where we use alt_usage_data method as a hardening, in oder to catch possible errors and fail safely with -1
, the problem is that version-app is not ready to handle integer -1 for all the values we send there
Should we remove now the usage of alt_usage_data
? we could adjust the fallback for each case if makes sense?
if values we sent are boolean what we should fallback into?
Proposal:
-
use
alt_usage_data
only when we deal with integer metrics -
adjust the fallback according to the type of the value we send back for each metric
- string -> fallback:
"-1"
- integer -> fallback
-1
- boolean -> fallback:
nil
? - array of strings -> array of -1?
["-1", "-1"]
- array of integers ->
[-1,-1]
- hash -> empty hash or the expected hash with keys and values -1(-1 integers or string as the type of values the hash has)
- string -> fallback:
Or adjust the version app to be able to treat the case it receives -1