Skip to content

fix: resolve issues 2027, 2028, 2029, and 2030 - #2032

Merged
blurbeast merged 4 commits into
LabsCrypt:mainfrom
bade2brazy:fix/issues-2027-2030
Oct 18, 2026
Merged

blurbeast merged 4 commits into
LabsCrypt:mainfrom
bade2brazy:fix/issues-2027-2030

Conversation

@bade2brazy

Copy link
Copy Markdown
Contributor

Summary

This PR addresses issues #2027, #2028, #2029, and #2030 across backend, frontend, scripts, and documentation.

Changes per Issue

1. Issue #2027: rateLimitService.checkRateLimit off-by-one

  • Changed condition from const allowed = currentCount < config.maxRequests; to const allowed = currentCount <= config.maxRequests; in backend/src/services/rateLimitService.ts.
  • Updated unit tests in backend/src/services/__tests__/rateLimitService.test.ts to assert that the N-th request (when currentCount === maxRequests) is allowed and requests beyond maxRequests are rejected.

2. Issue #2028: loanDueCheckCron duplicate spam and raw stroop formatting

  • In backend/src/cron/loanCheckCron.ts, updated the selection query to:
    • Exclude defaulted/liquidated loans (LoanDefaulted, LoanLiquidated, CollateralLiquidated).
    • Add a 24-hour notification deduplication check: AND NOT EXISTS (SELECT 1 FROM notifications n WHERE n.loan_id = le.loan_id AND n.type = 'repayment_due' AND n.created_at > NOW() - INTERVAL '24 hours').
  • Formatted loan.amount by dividing by 10_000_000 to convert raw stroops to standard units in user-facing notifications.
  • Added comprehensive unit tests in backend/src/cron/__tests__/loanCheckCron.test.ts.

3. Issue #2029: ERROR_CODE_MESSAGES missing SERVICE_UNAVAILABLE & CI guard scope

  • Added SERVICE_UNAVAILABLE: "The service is temporarily unavailable. Please try again later", to ERROR_CODE_MESSAGES in frontend/src/app/utils/transactionErrors.ts.
  • Fixed keyRegex character class in scripts/check-error-code-mappings.mjs from [A_Z0-9_]+ to [A-Z0-9_]+.
  • Scoped frontend key extraction specifically to the ERROR_CODE_MESSAGES object rather than searching the whole file.

4. Issue #2030: docs/webhooks.md endpoints, payload schema, and retry semantics

  • Updated docs/webhooks.md to document the actual /api/indexer/webhooks endpoints (GET /api/indexer/webhooks, POST /api/indexer/webhooks, DELETE /api/indexer/webhooks/:subscriptionId, and admin delivery/retry-status endpoints).
  • Updated request schema table to { callbackUrl, eventTypes, secret }.
  • Replaced outdated nested payload examples with the actual flat IndexedLoanEvent payload structure.
  • Updated timeout to 30 seconds and documented the 4-attempt retry schedule (5m, 15m, 45m).

Closes #2027
Closes #2028
Closes #2029
Closes #2030

…Crypt#2027)

- Change < to <= in rateLimitService.checkRateLimit so the Nth allowed request is not blocked
- Update test suite to assert Nth request allowance and blocking beyond maxRequests
…oop amount (LabsCrypt#2028)

- Exclude defaulted/liquidated loans (LoanDefaulted, LoanLiquidated, CollateralLiquidated)
- Add 24-hour notification deduplication check in loan due check query
- Format raw stroops as decimal amount (divided by 10,000,000) in notification message
- Add unit tests for loanCheckCron
…I check (LabsCrypt#2029)

- Add SERVICE_UNAVAILABLE to ERROR_CODE_MESSAGES in frontend/src/app/utils/transactionErrors.ts
- Fix keyRegex character class from [A_Z0-9_]+ to [A-Z0-9_]+ in check-error-code-mappings.mjs
- Scope key verification specifically to ERROR_CODE_MESSAGES object body
…semantics (LabsCrypt#2030)

- Update documentation to reflect actual /api/indexer/webhooks endpoints
- Document { callbackUrl, eventTypes, secret } subscription schema
- Update payload examples to flat IndexedLoanEvent structure
- Document 30-second timeout, 4-attempt retry policy, and retry processor schedule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment