Unfilter Content-Type param in API logs
What does this MR do and why?
Related: 20963: Unfilter Content-Type param in API logs ... (#584233)
During a recent incident (Commits API returning 400 errors), engineers couldn't debug content-type parsing issues because Content-Type showed as [FILTERED] in logs.
"params": [
{
"key": "Content-Type",
"value": "[FILTERED]"
The content filter was too broad - it filtered any param containing "content", including Content-Type. This MR changes the content filter from a symbol (substring match) to an exact-match regex (/\Acontent\z/i):
- `content` param → still filtered (may contain sensitive file data)
- `Content-Type` param → now visible (just a MIME type like `application/json`)
How to set up and validate locally
For the commit endpoint.
- Make a request to the commit endpoint
➜ curl -s -X POST "http://localhost:3000/api/v4/projects/1/repository/commits" \
-H "Content-Type: text/plain" \
-H "PRIVATE-TOKEN: <your-private-token>" \
-d '{}'
- Check the log
➜ tail -1 log/api_json.log | python3 -m json.tool | grep -A 3 '"params"'
3 You should see unfiltered Content-Type
"params": [
{
"key": "Content-Type",
"value": "text/plain"
For the file endpoint.
- Make a request to the file endpoint
➜ curl -s -X POST "http://localhost:3000/api/v4/projects/22/repository/files/test.txt" \
-H "Content-Type: application/json" \
-H "PRIVATE-TOKEN: <your-private-token>" \
-d '{}'
- Check the log
➜ tail -1 log/api_json.log | python3 -m json.tool | grep -A 3 '"params"'
3 You should see unfiltered Content-Type
"params": [
{
"key": "Content-Type",
"value": "application/json"
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Emma Park