Skip to content

AgentError::Db(String) erases DbError — prevents structured error handling downstream #4496

@bug-ops

Description

@bug-ops

Description

AgentError::Db in crates/zeph-core/src/agent/error.rs:115 is declared as Db(String), which erases the typed DbError from zeph-db. All three call sites in shadow_sentinel.rs use .map_err(|e| AgentError::Db(e.to_string())), destroying the original DbError structure.

zeph-db is already a direct dependency of zeph-core, and DbError implements std::error::Error, so a transparent #[from] conversion is possible without adding any new dependency.

Reproduction Steps

  1. crates/zeph-core/src/agent/error.rs:115Db(String) variant
  2. crates/zeph-core/src/agent/shadow_sentinel.rs:334, :364, :397 — all call .map_err(|e| AgentError::Db(e.to_string()))

Expected Behavior

#[error(transparent)]
Db(#[from] zeph_db::DbError),

This allows callers to pattern-match on DbError::Sqlx, DbError::Migration, etc., and preserves the full error chain for structured logging and observability.

Actual Behavior

DbError is converted to a string at the call site. Callers cannot distinguish between a connection failure, migration failure, or query error.

Environment

  • Version: HEAD 1d8a03a
  • Features: core

Logs / Evidence

crates/zeph-core/src/agent/error.rs:115
crates/zeph-core/src/agent/shadow_sentinel.rs:334,364,397

Metadata

Metadata

Assignees

Labels

P3Research — medium-high complexitycorezeph-core craterefactorCode refactoring without functional changes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions