Skip to content

fix(admin): add proper validation for campaign fee override (#531) - #733

Open
thebabalola wants to merge 1 commit into
Iris-IV:mainfrom
thebabalola:feat/fix-fee-override-validation
Open

fix(admin): add proper validation for campaign fee override (#531)#733
thebabalola wants to merge 1 commit into
Iris-IV:mainfrom
thebabalola:feat/fix-fee-override-validation

Conversation

@thebabalola

Copy link
Copy Markdown

Closes #531

Summary of Changes

Fixes validation bug where per-campaign fee overrides above 10,000 basis points (100%) were not properly validated on input.

What Changed

  • New error type: Added Error::InvalidFeeOverride to src/errors.rs (46th variant)
  • Strong validation: Updated set_campaign_fee_override in src/admin.rs to:
    • Reject fee_bps > PLATFORM_FEE_ABSOLUTE_MAX_BPS (10,000) → returns InvalidFeeOverride
    • Reject fee_bps > PLATFORM_FEE_MAX_BPS (1,000) → returns InvalidFeeOverride
  • Updated test: test_campaign_fee_override_above_max_rejected now expects InvalidFeeOverride instead of general ValidationFailed
  • Added edge case test: Verifies that exactly 10,000 bps (100%) is correctly rejected

Key Design Decisions

  1. Separate error variant: Using a dedicated InvalidFeeOverride error instead of the generic ValidationFailed makes it clear why the validation failed in logs and event payloads
  2. Two-tier validation:
    • Hard limit at 100% (PLATFORM_FEE_ABSOLUTE_MAX_BPS = 10,000) prevents nonsensical >100% fees
    • Platform max at 10% (PLATFORM_FEE_MAX_BPS = 1,000) enforces business policy

Testing / Local Verification

cargo test test_campaign_fee_override_above_max_rejected

Expected result: All tests pass with the new error validation

Security Impact

This fix prevents a scenario where an admin could set campaign fees above 100%, which would result in donors paying more than they intended. The validation ensures fees are always within reasonable bounds.

Fixes validation bug where per-campaign fee overrides above 10000 basis points (100%) were not properly rejected.

Changes:
- Add InvalidFeeOverride error type to src/errors.rs
- Replace ValidationFailed with InvalidFeeOverride in set_campaign_fee_override
- Strengthen validation to reject fee_bps > PLATFORM_FEE_ABSOLUTE_MAX_BPS (10000)
- Update test to expect InvalidFeeOverride instead of ValidationFailed
- Add test for edge case: exactly 10000 bps should be rejected

Fixes issue Iris-IV#531: set_campaign_fee_override: per-campaign fee set to 10001+ basis points is not validated on input
@drips-wave

drips-wave Bot commented Aug 2, 2026

Copy link
Copy Markdown

@thebabalola Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@thebabalola

Copy link
Copy Markdown
Author

hey, fixed the fee override validation bug for #531. added a dedicated InvalidFeeOverride error type and strengthened the validation to properly reject fees above 100% (10,000 bps). ready for review!

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.

[Bug] set_campaign_fee_override: per-campaign fee set to 10001+ basis points is not validated on input

1 participant