Skip to content

[fix] Reject inverted budget ranges in job validation (#2853)#6497

Open
xiaofengzii wants to merge 1 commit into
SecureBananaLabs:mainfrom
xiaofengzii:agent/job-budget-fix-2853-v2
Open

[fix] Reject inverted budget ranges in job validation (#2853)#6497
xiaofengzii wants to merge 1 commit into
SecureBananaLabs:mainfrom
xiaofengzii:agent/job-budget-fix-2853-v2

Conversation

@xiaofengzii

Copy link
Copy Markdown

Summary

This PR fixes the issue where createJobSchema accepts payloads where �udgetMax is lower than �udgetMin, creating invalid job records.

Changes

  1. Modified �pps/api/src/validators/job.js:

    • Added .refine() to createJobSchema to validate that �udgetMax >= budgetMin
    • Created a separate updateJobSchema (instead of using .partial()) with the same validation logic that only checks when both fields are present
  2. Added �pps/api/src/tests/job.test.js:

    • Comprehensive test coverage for budget validation
    • Tests for rejection of inverted ranges
    • Tests for acceptance of valid ranges
    • Tests for equal budgetMin and budgetMax
    • Tests for partial update scenarios

Verification

All tests pass:

  • createJobSchema rejects inverted budget ranges (budgetMax < budgetMin)
  • createJobSchema accepts valid budget ranges (budgetMax >= budgetMin)
  • createJobSchema accepts equal budgetMin and budgetMax
  • updateJobSchema rejects inverted budget ranges when both are present
  • updateJobSchema accepts valid budget ranges
  • updateJobSchema accepts single budget field

Related Issues

- Add refinement to createJobSchema to ensure budgetMax >= budgetMin
- Create separate updateJobSchema with budget validation for partial updates
- Add comprehensive tests for both schemas
- Fixes SecureBananaLabs#2853

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Job validation should reject inverted budget ranges

1 participant