Commit e5aeb0be authored by Catalin Irimie's avatar Catalin Irimie

Add logging handling for API integer params

When encoding the values to be logged with lograge we handled all
cases except Integer, which means legit int parameters being sent
to the API would be logged as null, this adds encoding for integer
parameters as well.
parent 75ac49a4
---
title: Fix logging handling for API integer params
merge_request: 46551
author:
type: fixed
...@@ -41,6 +41,8 @@ module Gitlab ...@@ -41,6 +41,8 @@ module Gitlab
data.map! { |v| utf8_encode_values(v) } data.map! { |v| utf8_encode_values(v) }
when String when String
encode_utf8(data) encode_utf8(data)
when Integer
utf8_encode_values(data.to_s)
end end
end end
end end
......
...@@ -15,7 +15,8 @@ RSpec.describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do ...@@ -15,7 +15,8 @@ RSpec.describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do
path: '/api/v4/projects/1', path: '/api/v4/projects/1',
params: { params: {
'description': '[FILTERED]', 'description': '[FILTERED]',
'name': 'gitlab test' 'name': 'gitlab test',
'int': 42
}, },
host: 'localhost', host: 'localhost',
remote_ip: '127.0.0.1', remote_ip: '127.0.0.1',
...@@ -44,7 +45,8 @@ RSpec.describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do ...@@ -44,7 +45,8 @@ RSpec.describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do
expect(params).to eq([ expect(params).to eq([
{ 'key' => 'description', 'value' => '[FILTERED]' }, { 'key' => 'description', 'value' => '[FILTERED]' },
{ 'key' => 'name', 'value' => 'gitlab test' } { 'key' => 'name', 'value' => 'gitlab test' },
{ 'key' => 'int', 'value' => '42' }
]) ])
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment