Conversation
Add comprehensive error response specification for campus API. Defines error envelope structure, validation error format, and environment-specific behavior for debug information. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement spec-compliant error envelope structure for all API error responses.
Changes:
- Update ErrorConstant enum: add INTERNAL_ERROR, VALIDATION_FAILED
- Update APIError.to_dict() to return nested error envelope:
{"error": {"code": "...", "message": "...", "details": {}, "request_id": null}}
- Update InternalError to use INTERNAL_ERROR constant
- Update error handlers to remove nested details in production
- Update all contract tests to assert new error format
- Update contract test README documentation
Breaking change: Error responses now use nested structure.
Old: {"error_code": "UNAUTHORIZED", "message": "...", "details": {}}
New: {"error": {"code": "UNAUTHORIZED", "message": "...", "details": {}, "request_id": null}}
Reference: campus/api/docs/api-error-spec.md
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive phased implementation plan for the error handling specification refactor. Phase 1 is already complete. Reference: campus/api/docs/api-error-spec-refactor-plan.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…Phase 2 Add FieldError TypedDict and ValidationError class (status 422) with to_dict() that adds errors array to error envelope. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… Phase 3 - Update unpack_into to collect field errors instead of raising KeyError - Raise ValidationError with structured FieldError objects for missing params - Update refactor plan to mark Phase 3 complete Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Mark Phase 3 as complete with commit reference - Mark Phase 3.2 as deferred - Update test command to use Poetry and run_tests.py - Document test results Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive test coverage for API error specification compliance: - TestErrorEnvelope: verifies all error types have correct envelope structure - TestValidationErrors: tests ValidationError with field-level errors - TestErrorCodes: validates error code format (UPPER_SNAKE_CASE) and mapping - TestEnvironmentSpecificBehavior: tests dev vs prod behavior for tracebacks All 103 unit tests and 18 integration tests pass. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 5 (Client-side updates for campus-api-python) is now complete: - Added FieldError and ValidationError classes to client - Updated APIError with request_id, details, errors, notes fields - Updated with_status_code() to parse new error envelope format - Added backward compatibility for legacy error format - Added 17 tests for error parsing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 6 of API Error Specification implementation: Documentation: - Add OpenAPI 3.0 spec at campus/api/docs/openapi.yaml - Define ErrorEnvelope, Error, ValidationError, and FieldError schemas - Add reusable error response objects (400, 401, 403, 404, 409, 422, 500) - Include error code documentation and examples - Remove migration guide from refactor plan (no users yet, campus in dev) All phases now complete: - Phase 1: Core error structure ✅ - Phase 2: Validation error structure ✅ - Phase 3: Update validation code ✅ - Phase 4: Add error response tests ✅ - Phase 5: Client-side updates ✅ - Phase 6: Documentation ✅ Reference: campus/api/docs/api-error-spec.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Phase 6 of API Error Specification implementation:
Documentation:
All phases now complete:
Reference: campus/api/docs/api-error-spec.md
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com