refactor(backend): extract punishment *Api interfaces, fix template-delete FK bug - #129
Open
TheMeinerLP wants to merge 1 commit into
Open
refactor(backend): extract punishment *Api interfaces, fix template-delete FK bug#129TheMeinerLP wants to merge 1 commit into
TheMeinerLP wants to merge 1 commit into
Conversation
…elete FK bug Four items from specs/002-punishment-core/tasks.md's Polish phase: - T027: Extract PunishmentApi and PunishmentTemplateApi (routing + @Operation/@apiresponse), both controllers now implement their interface per micronaut-openapi-contract, following the existing PlayerLookupApi precedent. - T025: Document PunishmentApplicationService.apply/revoke's read-modify-write race window in a class Javadoc, matching EloService's documented-limitation style. - T029 (real correctness bug, not just layering): DELETE /template/delete/{id} previously let an unhandled DB foreign-key exception surface as a raw 500 whenever a punishment still referenced the template - contradicting spec US5 Acceptance Scenario 3 and FR-010. PunishmentTemplateService.remove() now checks PunishmentRepository.existsByTemplate_Identifier first and returns a clean 409 Conflict instead. - T031: Documented RedisTopology's hardcoded key/channel constants as intentional - it's a wire protocol shared with every Velocity proxy, not a per-side tunable, so making it independently env-var configurable on each side risks silent drift/mismatch. Deliberately not included: T026 (DTO/Error-variant consolidation) and T028 (snapshotting a template's reason onto PunishmentEntity, which needs a new Liquibase changeset) - both real, higher-risk changes that need their own scoping decision. Verified: compiles, generated OpenAPI spec still documents all moved endpoints, and a live Docker test confirmed template CRUD, punishment apply/revoke/list, and specifically the new 409-on-in-use-template-delete behavior (previously an unhandled 500) all work correctly.
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.
Summary
Four items from
specs/002-punishment-core/tasks.md's Polish phase:PunishmentApiandPunishmentTemplateApi(routing +@Operation/@ApiResponse), both controllers nowimplementtheir interface permicronaut-openapi-contract, following the existingPlayerLookupApiprecedent in this codebase.PunishmentApplicationService.apply/revoke's read-modify-write race window in a class Javadoc, matchingEloService's documented-limitation style.DELETE /template/delete/{id}previously let an unhandled DB foreign-key exception surface as a raw500whenever a punishment still referenced the template — contradicting spec US5 Acceptance Scenario 3 and FR-010's "let network operators... remove" a template.PunishmentTemplateService.remove()now checksPunishmentRepository.existsByTemplate_Identifierfirst and returns a clean 409 Conflict instead.RedisTopology's hardcoded key/channel constants as intentional — it's a wire protocol shared with every Velocity proxy, not a per-side tunable, so making it independently env-var configurable on each side risks silent drift/mismatch between backend and proxy.Deliberately not included: T026 (DTO/
Error-variant consolidation) and T028 (snapshotting a template'sreasonontoPunishmentEntity, which needs a new Liquibase changeset) — both real, higher-risk changes (breaking wire format / a schema migration) that need their own explicit scoping decision.Test plan
./gradlew :backend:compileJavasucceedsDELETE /template/delete/{id}now returns409instead of an unhandled500; confirmed deleting an unused template still returns200, and a nonexistent template still returns404