Skip to content

Handle errors when repository is empty

Arpit Gogia requested to merge patch-arpit-387492 into master

What does this MR do and why?

Catches an error in the Security configuration workflow, caused when the repository is empty i.e. it has not been initialized.

Relevant issue: #387492 (closed)

Error Response

Container Scanning/Dependency Scanning/Secret Detection
[
    {
        "data": {
            "configureDependencyScanning": null
        },
        "errors": [
            {
                "message": "You must \u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"http://172.16.123.1:3000/help/user/project/repository/index.md#add-files-to-a-repository\"\u003eadd at least one file to the repository\u003c/a\u003e before using Security features",
                "locations": [
                    {
                        "line": 2,
                        "column": 3
                    }
                ],
                "path": [
                    "configureDependencyScanning"
                ]
            }
        ]
    }
]
SAST
[
    {
        "data": {
            "project": {
                "id": "gid://gitlab/Project/20",
                "sastCiConfiguration": null,
                "__typename": "Project"
            }
        },
        "errors": [
            {
                "message": "You must \u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"http://172.16.123.1:3000/help/user/project/repository/index.md#add-files-to-a-repository\"\u003eadd at least one file to the repository\u003c/a\u003e before using Security features",
                "locations": [
                    {
                        "line": 4,
                        "column": 5
                    }
                ],
                "path": [
                    "project",
                    "sastCiConfiguration"
                ]
            }
        ]
    }
]

Screenshots or screen recordings

Dependency Scanning/Container Scanning/Secret Detection image
SAST image

How to set up and validate locally

  1. Create a new blank project
  2. Go to "Security & Compliance" -> "Configuration"
  3. Try to configure one of the above security features using an MR ("Configure with merge request" button)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Arpit Gogia

Merge request reports