domain: MicropubError::InsufficientScope carries a string where the Scope enum exists #71

Open
opened 2026-07-03 01:43:18 +00:00 by rosa · 0 comments
Owner

Found during a code review of the domain crate.

Location: crates/domain/src/errors.rs:92; call sites services.rs:494/552/576
Type: Cleanup / altitude — stringly-typed data

Problem

MicropubError::InsufficientScope(&static str) carries a bare string literal ("create"/"delete"/"update") even though the Scope enum with those variants and as_str() already exists.

Cost

A typo (e.g. "crate") compiles fine and produces a wrong error message and wrong WWW-Authenticate/JSON scope hint, and the adapter must string-compare to know which scope was missing.

Suggested fix

Change to InsufficientScope(Scope) and let the Display impl derive the wire string.

Found during a code review of the `domain` crate. **Location:** `crates/domain/src/errors.rs:92`; call sites `services.rs:494`/`552`/`576` **Type:** Cleanup / altitude — stringly-typed data ## Problem `MicropubError::InsufficientScope(&static str)` carries a bare string literal ("create"/"delete"/"update") even though the `Scope` enum with those variants and `as_str()` already exists. ## Cost A typo (e.g. "crate") compiles fine and produces a wrong error message and wrong WWW-Authenticate/JSON scope hint, and the adapter must string-compare to know which scope was missing. ## Suggested fix Change to `InsufficientScope(Scope)` and let the Display impl derive the wire string.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rosa/vernier#71
No description provided.