Refactor dependency config file parsing error messages
What does this MR do and why?
Background
The Repository X-Ray is a feature that scans a repository for dependency manager configuration files and parses a list of library names/versions from those files. Its core functionality involves the ConfigFiles::Base class, which contains the logic to parse and extract libraries from the file content.
This MR
As part of https://gitlab.com/gitlab-org/gitlab/-/issues/509031, we will be introducing additional sanitization and validation logic to the parsed library name and version strings. In preparation for this, we are refactoring the ConfigFiles::Base class and related specs to better accommodate the new logic and improve its readability. It will also help to later distinguish parsing errors from string validation errors.
Specifically, in this MR, we:
- Separate the data type errors for library name and version (this will help with monitoring and debugging in the future.)
- Update the error messages to be more indicative of parsing problems rather than string validation problems.
- Since the errors may not be due to parsing problems only later, we refactor the shared examples to use the generic term
expected_error_messageinstead ofexpected_parsing_error_message.
References
- Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/509031
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.