feat: observability rate limiting error envelope#682
Open
rachealkenny wants to merge 8 commits into
Open
Conversation
|
@rachealkenny is attempting to deploy a commit to the Cedarich's projects Team on Vercel. A member of the Team first needs to authorize it. |
…ty-rate-limiting-error-envelope
…bound calls (Pulsefy#557) Adds correlation ID propagation to outbound HTTP requests for end-to-end traceability. Changes: - Add CorrelationPropagationUtil for managing correlation IDs in outbound calls - Create OutboundCorrelationInterceptor to ensure correlation ID availability - Add CorrelationModule to provide correlation utilities globally - Extend correlation-id.util.ts with extractCorrelationId and getCorrelationHeaders helpers - Propagate correlation ID to AI-service OCR calls in verification.service.ts - Update README to reflect project status This enables consistent traceability across the entire request chain, making it easier to debug and monitor distributed operations.
Pulsefy#556) Implements consistent error response format across all API endpoints with standardized error codes and enhanced error details. Changes: - Add ErrorResponseDto with standardized error envelope structure (code, message, errorCode, timestamp, path, traceId, correlationId) - Define ERROR_CODES constants for programmatic error handling - Enhance AllExceptionsFilter to return standardized error responses - Add helper methods to ApiResponseDto for common error scenarios (validationFail, notFound, unauthorized, forbidden, conflict, etc.) - Create StandardErrorResponses decorator for Swagger documentation - Add comprehensive E2E tests covering error envelope for 6+ error cases The error envelope now includes: - HTTP status code (code) - Human-readable message - Machine-readable errorCode - Timestamp and request path - traceId and correlationId for tracing - Structured validation error details
…lsefy#551) Adds centralized rate limit configuration with environment-aware policies and per-endpoint customizability. Changes: - Add RateLimitConfig with policies for public, auth, apiKey, admin, webhook, search, and health endpoint groups - Support environment variable overrides for production/testnet - Implement getRateLimitPolicy helper with wildcard pattern matching - Add @ratelimit, @SkipRateLimit, and helper decorators for per-endpoint overrides - Enhance AdaptiveRateLimitGuard to use config-based policies with backward compatibility - Add rate limit response headers (X-RateLimit-Limit, Remaining, Policy) - Include retryAfter and resetIn in rate limit error responses - Comprehensive E2E tests covering guard behavior on key endpoints Environment overrides: - RATE_LIMIT_*_LIMIT and RATE_LIMIT_*_WINDOW env vars - Different defaults for development, test, and production environments
Resolves TypeScript compilation errors across multiple test files by
fixing import paths, enum usage, and type assertions.
Changes:
- Fix import paths from absolute ('src/...') to relative ('../...')
- Use correct VerificationStatus enum (VERIFIED instead of COMPLETED)
- Add CampaignStatus enum import and use proper enum values
- Create createMockRequest helper for proper Express Request typing
- Add type guards for nextCursor in union pagination types
- Fix PrismaService mock with proper type assertions
- Add MockPrismaService type for better type safety
- Update mock method calls with proper jest.Mock type assertions
Files affected:
- src/audit/webhook.controller.spec.ts
- src/webhooks.service.spec.ts
- test/aid-escrow.integration.spec.ts
- test/verification-review-queue.e2e-spec.ts
No functional changes - test fixes only.
Applies consistent code formatting and fixes ESLint violations across the backend codebase. Changes: - Fix unused imports and variables (UseInterceptors, prisma, window) - Replace this.getErrorDescription with direct function call - Fix type assertions for method access in tests - Format long lines and function signatures for readability - Add trailing newlines at end of files - Remove redundant line breaks in test assertions - Fix import formatting across multiple files Files affected: - src/common/decorators/standard-error.decorator.ts - src/common/decorators/rate-limit.decorator.ts - src/common/utils/correlation-propagation.util.ts - src/webhooks.service.spec.ts - test/error-envelope.e2e-spec.ts - test/rate-limit.e2e-spec.ts - test/aid-escrow.integration.spec.ts - test/verification-review-queue.e2e-spec.ts - And various other controller, guard, and service files No functional changes - code formatting and linting only.
Resolves failing test suites by adding missing dependencies and improving database connection handling. Changes: - Add CorrelationPropagationUtil mock to VerificationService tests - Add VerificationMetadataService mock using string token - Add STELLAR_CHAIN_ID and STELLAR_NETWORK to config mock - Fix riskLevel type with 'as const' for type safety - Refactor idempotency.spec.ts with proper database connection handling: - Add buildConnectionString helper with default postgres:postgres credentials - Add testDatabaseConnection with retry logic - Add createTestDatabase and dropTestDatabase helpers - Use UUID-based unique database names for test isolation - Gracefully skip tests when database is unavailable This ensures tests pass both locally and in CI environments without requiring manual database setup. Test Suites: 2 passing
|
@rachealkenny 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! 🚀 |
Contributor
Author
|
@Cedarich please, review. |
Contributor
|
@rachealkenny please fix lint |
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.
Implement request correlation propagation, standardized error envelope, and configurable rate limiting
Overview
This PR adds request correlation propagation for distributed tracing, standardizes error responses across all controllers, and implements configurable rate limiting per endpoint group.
Changes
Request Correlation Propagation (#557)
Standardized Error Envelope (#556)
{ code, message, correlationId, details }Rate Limit Policy Map (#551)
Files Added
Files Modified
Closes #557
Closes #556
Closes #551