Fix/deterministic error ordering#714
Open
afurious wants to merge 5 commits intoJagadeeshftw:masterfrom
Open
Conversation
…applications handlers - Define clear validation precedence hierarchy for all handlers - Reorder validation checks to follow consistent priority: 1. Service Availability (db, config) 2. Input Format Validation (params parsing) 3. Authentication (user verification) 4. Request Body Validation (payload checks) 5. External Account Linking (GitHub account) 6. Resource Existence (project/issue lookup) 7. Database/Internal Errors (unexpected failures) 8. Authorization (permission checks) 9. Business Logic Constraints (business rules) 10. External Service Errors (GitHub API) - Apply() handler: Reordered to check service → input → auth → body → linking → existence → business logic - PostBotComment() handler: Reordered to separate existence, internal errors, authorization, and business logic - Withdraw() handler: Reordered to check existence before authorization, separate internal errors - Assign() handler: Reordered to separate existence, internal errors, authorization, and business logic - Unassign() handler: Reordered to separate existence, internal errors, authorization, and business logic - Reject() handler: Reordered to separate existence, internal errors, authorization, and business logic This change improves debuggability and predictability by ensuring the same inputs always produce the same error, regardless of execution path.
- Define 11-level error precedence hierarchy in ERROR_PRECEDENCE.md - Document error priority for all contract error codes - Reorder validation checks in bounty_escrow contract functions: * lock_funds: Pause → Init → Auth → State conflicts → Business logic * release_funds: Pause → Init → Auth → Existence → State conflicts → Resource state * release_with_capability: Pause → Existence → State → Capability → Business logic → Availability - Add comprehensive error precedence tests covering multi-error scenarios: * test_precedence_paused_over_not_initialized * test_precedence_not_initialized_over_bounty_exists * test_precedence_bounty_exists_over_amount_validation * test_precedence_not_found_over_invalid_state * test_precedence_claim_pending_over_invalid_state * test_precedence_invalid_state_over_invalid_amount * test_precedence_invalid_amount_over_insufficient_funds * test_precedence_amount_below_minimum_checked_in_order * test_precedence_amount_above_maximum_checked_in_order * test_precedence_comprehensive_lock_funds * test_precedence_comprehensive_release_funds - Ensure consistent validation pattern across all entry points This change improves debuggability and predictability by ensuring the same inputs always produce the same error, regardless of contract version.
Resolved conflicts in contracts/bounty_escrow/contracts/escrow/src/lib.rs: - Combined test module imports (test_risk_flags + error_precedence_tests) - Integrated deterministic error ordering in lock_funds and release_funds - Maintained proper error priority checks from both branches
|
@afurious is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #612
#612 Ensure Deterministic Error Ordering and Prioritization