Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
220e0f01
Commit
220e0f01
authored
Feb 08, 2022
by
Alex Kalderimis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nil safety for Json.parse
Includes a more helpful error message if data is nil in the performance bar.
parent
8ec7a386
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
lib/gitlab/json.rb
lib/gitlab/json.rb
+3
-0
lib/gitlab/performance_bar/stats.rb
lib/gitlab/performance_bar/stats.rb
+4
-2
No files found.
lib/gitlab/json.rb
View file @
220e0f01
...
...
@@ -16,6 +16,9 @@ module Gitlab
# @return [Boolean, String, Array, Hash]
# @raise [JSON::ParserError] raised if parsing fails
def
parse
(
string
,
opts
=
{})
# Parse nil as nil
return
if
string
.
nil?
# First we should ensure this really is a string, not some other
# type which purports to be a string. This handles some legacy
# usage of the JSON class.
...
...
lib/gitlab/performance_bar/stats.rb
View file @
220e0f01
...
...
@@ -25,8 +25,8 @@ module Gitlab
log_queries
(
id
,
data
,
'active-record'
)
log_queries
(
id
,
data
,
'gitaly'
)
log_queries
(
id
,
data
,
'redis'
)
rescue
StandardError
=>
e
rr
logger
.
error
(
message:
"failed to process request id
#{
id
}
:
#{
e
rr
.
message
}
"
)
rescue
StandardError
=>
e
logger
.
error
(
message:
"failed to process request id
#{
id
}
:
#{
e
.
message
}
"
)
end
private
...
...
@@ -34,6 +34,8 @@ module Gitlab
def
request
(
id
)
# Peek gem stores request data under peek:requests:request_id key
json_data
=
@redis
.
get
(
"peek:requests:
#{
id
}
"
)
raise
"No data for
#{
id
}
"
if
json_data
.
nil?
Gitlab
::
Json
.
parse
(
json_data
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment