-
Notifications
You must be signed in to change notification settings - Fork 375
Handle multiple requirement mapping sets in libraries #1943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes refactor and enhance the validation, error reporting, and initialization logic for requirement mappings and related sets in the library import process. They improve error accumulation, unify handling of singular and plural fields for mappings and risk matrices with backward compatibility, correct off-by-one errors in error messages, update code style with type hints, and remove unused imports. Additionally, a typographical error in documentation is fixed, and multiple YAML library files are updated to rename singular keys to plural forms and increment version numbers. The filtering logic in library views is adjusted for backward compatibility with deprecated object type names. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LibraryImporter
participant RequirementMappingSetImporter
participant RequirementMappingImporter
User->>LibraryImporter: import_objects(library_object)
LibraryImporter->>LibraryImporter: init()
LibraryImporter->>RequirementMappingSetImporter: init_requirement_mapping_set(requirement_mapping_sets)
loop For each mapping set
RequirementMappingSetImporter->>RequirementMappingSetImporter: init()
RequirementMappingSetImporter->>RequirementMappingSetImporter: is_empty()
RequirementMappingSetImporter->>RequirementMappingSetImporter: init_requirement_mappings(requirement_mappings)
loop For each mapping
RequirementMappingSetImporter->>RequirementMappingImporter: is_valid()
end
end
LibraryImporter-->>User: Return accumulated errors or success
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (10)
🔇 Additional comments (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/library/utils.py
(14 hunks)documentation/architecture/data-model.md
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: enterprise-startup-docker-compose-test
- GitHub Check: startup-functional-test (3.12)
- GitHub Check: startup-docker-compose-test
- GitHub Check: functional-tests (3.12, chromium)
- GitHub Check: enterprise-functional-tests (3.12, chromium)
- GitHub Check: enterprise-startup-functional-test (3.12)
- GitHub Check: test (3.12)
- GitHub Check: build (3.12)
- GitHub Check: Analyze (python)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
documentation/architecture/data-model.md (1)
95-95
: Typo fixed – looks goodThe ER diagram now uses the correct entity name
REQUIREMENT_MAPPING_SET
. ✅
if ( | ||
"requirement_mapping_set" in library_objects | ||
and "requirement_mapping_ses" in library_objects | ||
): | ||
return "A library can't have both 'requirement_mapping_set' and 'requirement_mapping_ses' objects fields." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo breaks mutual-exclusion check for requirement-mapping sets
The guard tests "requirement_mapping_ses"
instead of "requirement_mapping_sets"
, so the conflict is never detected and the associated error message is misleading.
- if (
- "requirement_mapping_set" in library_objects
- and "requirement_mapping_ses" in library_objects
- ):
- return "A library can't have both 'requirement_mapping_set' and 'requirement_mapping_ses' objects fields."
+ if (
+ "requirement_mapping_set" in library_objects
+ and "requirement_mapping_sets" in library_objects
+ ):
+ return "A library can't have both 'requirement_mapping_set' and 'requirement_mapping_sets' object fields."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if ( | |
"requirement_mapping_set" in library_objects | |
and "requirement_mapping_ses" in library_objects | |
): | |
return "A library can't have both 'requirement_mapping_set' and 'requirement_mapping_ses' objects fields." | |
if ( | |
"requirement_mapping_set" in library_objects | |
and "requirement_mapping_sets" in library_objects | |
): | |
return "A library can't have both 'requirement_mapping_set' and 'requirement_mapping_sets' object fields." |
key for key in ["risk_matrix", "risk_matrices"] if key in library_objects | ||
]: | ||
risk_matrix_data = library_objects[keys_found[0]] | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Singular risk_matrix
objects are not converted to a list
For backward compatibility you correctly turn a singular requirement mapping set into a list, but the same pattern is missing for risk matrices.
If a legacy YAML uses the (deprecated) risk_matrix
key with a single object, init_risk_matrices
will iterate over a dict and raise.
- risk_matrix_data = library_objects[keys_found[0]]
+ risk_matrix_data = library_objects[keys_found[0]]
+ if not isinstance(risk_matrix_data, list):
+ # Back-compat with the deprecated singular field
+ risk_matrix_data = [risk_matrix_data]
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
key for key in ["risk_matrix", "risk_matrices"] if key in library_objects | |
]: | |
risk_matrix_data = library_objects[keys_found[0]] | |
if ( | |
for keys_found in [ | |
key for key in ["risk_matrix", "risk_matrices"] if key in library_objects | |
]: | |
risk_matrix_data = library_objects[keys_found[0]] | |
+ if not isinstance(risk_matrix_data, list): | |
+ # Back-compat with the deprecated singular field | |
+ risk_matrix_data = [risk_matrix_data] | |
if ( | |
# ... | |
): | |
# existing logic… |
We want to be able to put any number of any type of objects in a library. Currently this is not the case for mapping_set and framework. It is the case for matrix, but the word is incorrect (should be matrices).
The change done is the following:
This approach make migration easy.
Summary by CodeRabbit
Bug Fixes
New Features
Refactor
Documentation