Skip to content

added support for loantype, pos and parentloanid to the gold payload#303

Merged
thomastomy5 merged 1 commit into
developfrom
feat/wf-topup
Jun 29, 2026
Merged

added support for loantype, pos and parentloanid to the gold payload#303
thomastomy5 merged 1 commit into
developfrom
feat/wf-topup

Conversation

@thomastomy5

@thomastomy5 thomastomy5 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Added stricter validation for image request details to ensure loan-related fields are consistent.
    • Requests now require a parent loan ID for top-up loans, and prevent it for new loans.
    • Improved input typing for loan type values to accept only supported options.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

ImageMetadata now constrains loan_type to new or top_up and adds model-level validation for parent_loan_id consistency.

Changes

Loan type metadata validation

Layer / File(s) Summary
Loan type constraint and field validation
wavefront/server/modules/gold_module/gold_module/models/gold_image_request.py
ImageMetadata now types loan_type as a literal value and validates parent_loan_id based on whether the loan is new or a top-up.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A hop, a skip, a bounded type,
My bunny nose says, “This feels right!”
New loans stay new, top-ups need aid,
With parent IDs neatly displayed.
Hoppy validation, swift and clean 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding loan type, pos, and parent loan ID support to the gold payload.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wf-topup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2c3a129 and 13bca91.

📒 Files selected for processing (1)
  • wavefront/server/modules/gold_module/gold_module/models/gold_image_request.py

Comment on lines +63 to +69
@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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

Suggested change
@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(...)`.

@thomastomy5 thomastomy5 merged commit 3fdd66f into develop Jun 29, 2026
9 checks passed
@thomastomy5 thomastomy5 deleted the feat/wf-topup branch June 29, 2026 06:33
vizsatiz pushed a commit that referenced this pull request Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants