Skip to content

fix(server): match Error::Validation instead of string in /memory/importance - #699

Merged
ajianaz merged 1 commit into
developfrom
fix/697-importance-error-dispatch
Jul 16, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/697-importance-error-dispatch

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

POST /memory/importance classified validation errors by string-matching the error message (e.to_string().contains("importance must be")\)). This couples the 400/500status to the exact wording of the validation message instore.rs::set_importance. If that wording ever changes, a 400 Bad Requestwould silently degrade to500`.

Fix: match the typed uteke_core::Error::Validation(_) variant instead — the same pattern already used by PUT /memory.

Before

Err(e) => {
    if e.to_string().contains("importance must be") {
        ctx.error_response_for(req, 400, e.to_string())
    } else {
        error!("Set importance error: {e}");
        ctx.error_response_for(req, 500, "Internal server error")
    }
}

After

Err(e) => match e {
    uteke_core::Error::Validation(_) => ctx.error_response_for(req, 400, e.to_string()),
    _ => {
        error!("Set importance error: {e}");
        ctx.error_response_for(req, 500, "Internal server error")
    }
},

Behavior is unchanged for current inputs (the validation message still contains "importance must be"), but the coupling is removed.

Closes #697

Checklist

  • cargo fmt clean
  • No logic change for valid/invalid inputs — only the status-code dispatch is hardened

…ortance

The /memory/importance handler classified validation errors via
e.to_string().contains("importance must be"), coupling the 400/500
status to the exact wording of the validation message in store.rs.
If that wording changes, a 400 would silently degrade to a 500.

Match the typed Error::Validation(_) variant instead, mirroring the
pattern already used by PUT /memory.

Closes #697
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 9fc9118 into develop Jul 16, 2026
8 checks passed
@ajianaz
ajianaz deleted the fix/697-importance-error-dispatch branch July 16, 2026 03:05
ajianaz added a commit that referenced this pull request Aug 13, 2026
…patch

fix(server): match Error::Validation instead of string in /memory/importance
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.

POST /memory/importance: fragile string-based error dispatch (400 silently degrades to 500)

1 participant