Skip to content

Backend feature: upload validation, metrics, health, custom errors#302

Open
Devdave-0x wants to merge 7 commits into
benelabs:mainfrom
Devdave-0x:feature/backend-issues-206-210-211-212
Open

Backend feature: upload validation, metrics, health, custom errors#302
Devdave-0x wants to merge 7 commits into
benelabs:mainfrom
Devdave-0x:feature/backend-issues-206-210-211-212

Conversation

@Devdave-0x
Copy link
Copy Markdown

@Devdave-0x Devdave-0x commented May 27, 2026

Implements backend upload validation, Prometheus metrics collection, health check endpoints, and a unified custom error type hierarchy. Four commits included: #206, #210, #211, #212.

closes #206
closes #210
closes #211
closes #212

- Add domain error types: FileError, DatabaseError, CacheError, AuthError, ExternalServiceError
- Implement unified AppError with From conversions for all domain types
- Map each variant to appropriate HTTP status code and machine-readable code
- Add ErrorResponse struct with optional details field
- Include unit tests for display, status mapping, and conversions
- Add ValidationConfig with max_size and allowed MIME type set
- Implement validate_upload() with size, file name, and MIME checks
- Magic-byte sniffing to detect actual MIME and compare with declared type
- sanitize_file_name() strips path traversal and null bytes
- Unit tests covering valid uploads, size limit, MIME mismatch, path traversal
- Add Counter, Gauge, and Histogram primitives with label support
- Implement MetricsRegistry with HTTP, error, cache, DB pool, and file upload metrics
- render() produces valid Prometheus text exposition format (v0.0.4)
- metrics_handler() Axum handler for GET /metrics
- RequestTimer RAII guard records request duration on drop
- Unit tests for all primitives and registry methods
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@Devdave-0x 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant