API requests log null parameters for Integer values
Summary
For API requests where the params are Integer
, the output logs in api_json.log
contain null
instead of the int.
For example - when importing projects from GitHub using the API, we ask for the repo_id to be an int. When it's an int, the api_json.log
says it's null instead, whereas a string works correctly.
Also, sharing a project with a group has two int parameters which don't log correctly.
Steps to reproduce
Import a project using an int, vs string and compare the results:
curl --request POST --url "$DOMAIN/api/v4/import/github" --header "content-type: application/json" --header "PRIVATE-TOKEN: $PAT" --data '{"personal_access_token": "'$GH_PAT'", "repo_id": '$PROJ', "target_namespace": "'$GROUP'", "new_name": "repo1"}'
curl --request POST --url "$DOMAIN/api/v4/import/github" --header "content-type: application/json" --header "PRIVATE-TOKEN: $PAT" --data '{"personal_access_token": "'$GH_PAT'", "repo_id": "'$PROJ'", "target_namespace": "'$GROUP'", "new_name": "repo2"}'
=>
root@cat:# tail -2 /var/log/gitlab/gitlab-rails/api_json.log | jq '.params | .[] | select(.key == "repo_id") | .value'
null
"123456789"
Then, share a project with a group:
curl --request POST --url "$DOMAIN/api/v4/projects/$PROJECT_ID" --header "content-type: application/json" --header "PRIVATE-TOKEN: $PAT" --data '{"group_id": 10, "group_access": 10}'
=>
root@cat:# tail -1 /var/log/gitlab/gitlab-rails/api_json.log | jq '.params | .[]'
{
"key": "group_id",
"value": null
}
{
"key": "group_access",
"value": null
}
What is the current bug behavior?
Incorrect logging of int parameters to the API requests.
What is the expected correct behavior?
The passed parameters being logged instead of null.
Relevant logs and/or screenshots
Mentioned above in the steps to reproduce.
Possible fixes
Since it's happening for all requests, I'm assuming something possibly going wrong with the grape_logging
gem.