-
Notifications
You must be signed in to change notification settings - Fork 5
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
0286 growth plan upload failure #3328
Conversation
📝 WalkthroughWalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 0
🧹 Outside diff range and nitpick comments (1)
src/components/engagement/engagement.repository.ts (1)
383-396
: Consider implementing a common file validation method.Both
updateLanguage
andupdateInternship
methods have similar file validation logic. Consider extracting this into a common private method to improve maintainability and reduce code duplication.+ private validateFileExists<T extends { id: string }>( + file: T | null, + fileType: string, + ): asserts file is T { + if (!file) { + throw new ServerException( + `Expected ${fileType} file to be created with the engagement`, + ); + } + } async updateLanguage( changes: UpdateLanguageEngagement, session: Session, changeset?: ID, ) { const { id, pnp, ...simpleChanges } = changes; if (pnp) { const engagement = await this.readOne(id, session); - if (!engagement.pnp) { - throw new ServerException( - 'Expected PnP file to be created with the engagement', - ); - } + this.validateFileExists(engagement.pnp, 'PnP'); await this.files.createFileVersion( { ...pnp, parentId: engagement.pnp.id, }, session, ); } } async updateInternship( changes: UpdateInternshipEngagement, session: Session, changeset?: ID, ) { const { id, mentorId, countryOfOriginId, growthPlan, ...simpleChanges } = changes; if (growthPlan) { const engagement = await this.readOne(id, session); - if (!engagement.growthPlan) { - throw new ServerException( - 'Expected Growth Plan file to be created with the engagement', - ); - } + this.validateFileExists(engagement.growthPlan, 'Growth Plan'); await this.files.createFileVersion( { ...growthPlan, parentId: engagement.growthPlan.id, }, session, ); } }Also applies to: 425-438
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
src/components/engagement/engagement.repository.ts
(2 hunks)src/components/engagement/engagement.service.ts
(0 hunks)
💤 Files with no reviewable changes (1)
- src/components/engagement/engagement.service.ts
🔇 Additional comments (2)
src/components/engagement/engagement.repository.ts (2)
383-396
: LGTM! Improved error handling for PnP file updates.
The added validation ensures that the PnP file exists before attempting to create a new version, preventing potential runtime errors. The error message is clear and descriptive.
425-438
: LGTM! Improved error handling for Growth Plan file updates.
The added validation ensures that the Growth Plan file exists before attempting to create a new version, preventing potential runtime errors. The error message is clear and descriptive.
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.
Yes
Monday Story 0286