added support for loantype, pos and parentloanid to the gold payload#303
Conversation
📝 WalkthroughWalkthrough
ChangesLoan type metadata validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@wavefront/server/modules/gold_module/gold_module/models/gold_image_request.py`:
- Around line 63-69: The GoldImageRequest `validate_loan_type_fields` model
validator only checks `loan_type` when it is present, so payloads with
`parent_loan_id` but no `loan_type` can still pass through. Update this
validator in `GoldImageRequest` to require `loan_type` whenever `parent_loan_id`
is provided, and raise a validation error if `parent_loan_id` is set while
`loan_type` is missing or incompatible before the request reaches
`image_service.process_image(...)`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f772c7ba-8c57-49d0-beb7-a61ce1901189
📒 Files selected for processing (1)
wavefront/server/modules/gold_module/gold_module/models/gold_image_request.py
| @model_validator(mode='after') | ||
| def validate_loan_type_fields(self): | ||
| if self.loan_type == 'top_up' and not self.parent_loan_id: | ||
| raise ValueError('parent_loan_id is required when loan_type is top_up') | ||
| if self.loan_type == 'new' and self.parent_loan_id is not None: | ||
| raise ValueError('parent_loan_id must be null when loan_type is new') | ||
| return self |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Require loan_type when parent_loan_id is provided.
This validator still accepts payloads where parent_loan_id is set but loan_type is omitted, so the new fields can reach image_service.process_image(...) in an inconsistent state.
Proposed fix
`@model_validator`(mode='after')
def validate_loan_type_fields(self):
+ if self.parent_loan_id is not None and self.loan_type is None:
+ raise ValueError('loan_type is required when parent_loan_id is provided')
if self.loan_type == 'top_up' and not self.parent_loan_id:
raise ValueError('parent_loan_id is required when loan_type is top_up')
if self.loan_type == 'new' and self.parent_loan_id is not None:
raise ValueError('parent_loan_id must be null when loan_type is new')
return self📝 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.
| @model_validator(mode='after') | |
| def validate_loan_type_fields(self): | |
| if self.loan_type == 'top_up' and not self.parent_loan_id: | |
| raise ValueError('parent_loan_id is required when loan_type is top_up') | |
| if self.loan_type == 'new' and self.parent_loan_id is not None: | |
| raise ValueError('parent_loan_id must be null when loan_type is new') | |
| return self | |
| `@model_validator`(mode='after') | |
| def validate_loan_type_fields(self): | |
| if self.parent_loan_id is not None and self.loan_type is None: | |
| raise ValueError('loan_type is required when parent_loan_id is provided') | |
| if self.loan_type == 'top_up' and not self.parent_loan_id: | |
| raise ValueError('parent_loan_id is required when loan_type is top_up') | |
| if self.loan_type == 'new' and self.parent_loan_id is not None: | |
| raise ValueError('parent_loan_id must be null when loan_type is new') | |
| return self |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@wavefront/server/modules/gold_module/gold_module/models/gold_image_request.py`
around lines 63 - 69, The GoldImageRequest `validate_loan_type_fields` model
validator only checks `loan_type` when it is present, so payloads with
`parent_loan_id` but no `loan_type` can still pass through. Update this
validator in `GoldImageRequest` to require `loan_type` whenever `parent_loan_id`
is provided, and raise a validation error if `parent_loan_id` is set while
`loan_type` is missing or incompatible before the request reaches
`image_service.process_image(...)`.
…303) added loantype, pos and parentloanid
Summary by CodeRabbit