Sign in or sign up before continuing. Don't have an account yet? Register now to get started.
Validate types of the fetched GitHub repository entities data
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=384176)
</details>
<!--IssueSummary end-->
The following discussion from https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103761 should be addressed:
* [ ] @nmalcolm started a [discussion](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/103761#note_1188810632):
> **Suggestion** Either here or elsewhere, let's do some strong typing. That way if someone tries weird stuff with passing json objects or arrays we'll fail early.
For now, we trust the data type that is returned from GitHub in `GitHub Project/GitHub Gists import` and filter out properties we are interested in via [representations](https://gitlab.com/gitlab-org/gitlab/-/tree/master/lib/gitlab/github_import/representation)
### Proposal
Use Json schema validation to make sure incoming data is in expected format/expected type. There's `JsonSchemaValidator` we can extend and use to validate the input from GitHub before importing repository entities. We should define custom schema for each kind of importing entity (pull request, collaborator, note etc.) based on GitHub Response schema and put them in app/validators/json_schemas. The import should be failed/halted in case the validation failed.
issue