CODEOWNERS syntax/format validation
Release notes
You can now see in the UI if your CODEOWNERS file has syntax errors.
Problem
Research justification: Help users better understand CODEOWNERS (&4498 - closed)
Code owners offers great flexibility, allowing multiple file locations, sections, and rules to be configured by users. However, code owners does not currently validate the information being entered into the file. This can lead to users experiencing problems such as:
- Creating rules for files/paths that don't exist
- Creating rules that create conflict with other existing rules
- Creating rules that don't apply because of incorrect syntax
The initial version in this MVP would return a true/false if the file is valid to be presented by the frontend. Details about why the file was invalid would be captured in a later version.
Further details
The future introduction of support for multiple code owners files will compound this problem and could lead to a degradation of the experience if validation does not follow soon.
This issue has been split out into a MVP (this issue) and a more advanced version captured in CODEOWNERS editor and validation tool (#389409 - closed)
Proposal
See epic: &4498 (closed)
Lint/verify that the CODEOWNERS file syntax/format is valid.
- Display status of syntax validity of code owners file when viewing in repository
Design
Requirements
Checks for the following scenarios as referenced in error handling in Code Owners.
- Entries with spaces
- Unparsable sections
- Malformed owners
- Inaccessible owners
- Zero owners
- Less than 1 required approvals
- When the code owners file has valid syntax
- Display checkmark icon with text
Syntax is valid.
- Display checkmark icon with text
- When the code owners file has syntax errors
- Display error icon with text
Contains {X} syntax errors. [> Show errors].
- Where X is equal to the total number of syntax errors
- Clicking on "Show errors" expands the list of errors
- When expanded, display a link to docs for text "How are errors handled?"
- Each of the type of errors is displayed as a bullet point.
- The reason it is in a list rather than a comma separated sentence is for easy parsing of the list. The vertical height of the list is not a concern because we want users to be aware of the errors.
- Clicking on the error name will expand to reveal the lines as a list where there is a syntax error.
- Display error icon with text
- Validation is done when the changes to codeowners is made.
- This result should be cached so that we don't need to do a validation every time the codeowners file is opened.
Availability and Testing
- Add feature specs for above 6 error scenarios and happy path scenario.
- Ensure multiple errors can be handled together.
- Test for expanding errors.
- Test count of errors.
- Ensure validation is performed on update also.
- Exploratory testing of feature.