Skip to content

Fold ValidateEntryType into WithEntryType#737

Merged
rdimitrov merged 2 commits intomainfrom
fold-validate-entry-type-into-option
Apr 20, 2026
Merged

Fold ValidateEntryType into WithEntryType#737
rdimitrov merged 2 commits intomainfrom
fold-validate-entry-type-into-option

Conversation

@rdimitrov
Copy link
Copy Markdown
Member

Summary

  • Drop the standalone service.ValidateEntryType helper and inline the switch directly into setEntryType, so WithEntryType is the single validation site for entry type strings (addresses @blkt's review nit on Implement PUT /v1/entries/{type}/{name}/claims endpoint #720).
  • Add an ErrInvalidEntryType sentinel so the handler can still map invalid input to HTTP 400 after validation moves inside the service layer.
  • Simplify mapEntryType — drop the redundant pre-check and let the switch default return the same sentinel.

Fixes #736

Test plan

  • task build
  • task lint-fix — 0 issues
  • task test — all unit and integration tests pass, including updated TestWithEntryType (asserts ErrorIs(err, ErrInvalidEntryType)) and the handler's unsupported entry type case (now exercises the service error path with a mock returning ErrInvalidEntryType).

🤖 Generated with Claude Code

Drop the standalone `service.ValidateEntryType` helper and inline the
switch directly into `UpdateEntryClaimsOptions.setEntryType`, so
`WithEntryType` is the single validation site for entry type strings.
The handler no longer pre-validates; instead, invalid types surface
from the option setter wrapped in the new `ErrInvalidEntryType`
sentinel, which the handler maps to HTTP 400. `mapEntryType` in the
database service drops its redundant pre-check and relies on the
switch default, which also returns the same sentinel.

Fixes #736
@rdimitrov rdimitrov requested a review from blkt April 20, 2026 16:29
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.63%. Comparing base (1cd9d2e) to head (c69b159).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/service/db/impl_entries.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #737      +/-   ##
==========================================
- Coverage   60.64%   60.63%   -0.01%     
==========================================
  Files         109      108       -1     
  Lines       10486    10480       -6     
==========================================
- Hits         6359     6355       -4     
+ Misses       3573     3572       -1     
+ Partials      554      553       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@blkt blkt enabled auto-merge (squash) April 20, 2026 16:58
@rdimitrov rdimitrov disabled auto-merge April 20, 2026 17:00
@rdimitrov rdimitrov merged commit 8c63e62 into main Apr 20, 2026
15 checks passed
@rdimitrov rdimitrov deleted the fold-validate-entry-type-into-option branch April 20, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fold ValidateEntryType into WithEntryType option

3 participants