Resource creation#9416
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR removes framework category normalization logic from the EditorService.create() method that was responsible for converting non-array framework category values to arrays before sending content creation requests to the API.
Key Changes:
- Removed 11 lines of code that iterated through framework categories and converted single values to arrays
- The logic was specifically handling cases where form inputs provided string values instead of arrays for framework category fields (e.g., board, medium, gradeLevel, subject)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -46,17 +46,6 @@ export class EditorService { | |||
| * @param req OBJECT | |||
| */ | |||
| create(req): Observable<ServerResponse> { | |||
There was a problem hiding this comment.
The removal of framework category normalization logic could cause API failures. The deleted code was converting non-array framework category values to arrays before sending them to the content creation API.
Form fields can use either select (single value) or multiSelect (array) input types for framework categories. Without this normalization, single-value selections from select dropdowns will be sent as strings instead of arrays, which may cause the API to reject the request if it expects array values for framework category fields (e.g., board, medium, gradeLevel, subject).
If this removal is intentional because the API now accepts both formats or the normalization has been moved elsewhere, please ensure:
- The API endpoint accepts both string and array values for framework category fields, or
- The form component or data generation logic now handles this normalization before calling
editorService.create()
Otherwise, consider restoring this logic or implementing the normalization in the generateData() method of the data-driven component.
| create(req): Observable<ServerResponse> { | |
| create(req): Observable<ServerResponse> { | |
| // Normalize framework category fields to arrays | |
| const frameworkCategories = ['board', 'medium', 'gradeLevel', 'subject']; | |
| frameworkCategories.forEach(field => { | |
| if (req.hasOwnProperty(field) && !_.isArray(req[field]) && !_.isNil(req[field])) { | |
| req[field] = [req[field]]; | |
| } | |
| }); |
SunbirdEd - Portal
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Please choose applicable option
Example
Type of change
Please choose appropriate options.
Checklist: