affaan-m/ECC · error
Remote dispatch request
Error message
Remote dispatch request {id} was not found after insert What it means
Same readback invariant as scheduled tasks but for remote dispatch requests: after INSERT, the store takes last_insert_rowid() and re-fetches via get_remote_dispatch_request. A None result means the just-inserted row vanished or the rowid was wrong, so `Remote dispatch request {id} was not found after insert` is raised.
Solutions
- Serialize insert+readback inside a transaction (BEGIN IMMEDIATE ... COMMIT).
- Audit for code paths that delete/process remote dispatch requests immediately after creation.
- Restrict the connection to a single thread or use a connection per thread so last_insert_rowid is correct.
- Verify the INSERT statement targets the intended table and that no BEFORE DELETE trigger interferes.
Defensive patterns
Strategy: try-catch
Try / catch
if let Err(e) = result {
if e.to_string().contains("was not found after insert") {
log::error!("dispatch request lost between insert and fetch: {e}");
// surface as 500 / retry with transactional insert
} else { return Err(e.into()); }
} Prevention
- Make create + readback atomic with a transaction.
- Pause consumer workers during bulk inserts or use row-status flags instead of deletion.
- Use a dedicated connection per thread to keep last_insert_rowid valid.
- Add a regression test that inserts while a consumer processes concurrently.
When it happens
Trigger: Row deleted by a concurrent processor between insert and fetch; last_insert_rowid() returning an id from a different table after a failed/no-op insert; unsynchronized multi-thread access to the shared connection.
Common situations: A dispatcher worker consuming requests concurrently while another inserts; connection reuse across statements; migration schemas where the INSERT hit a different table than expected.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- candidate alias integrity verification failed
- Scheduled task was not found after insert
- candidate alias collision with physical candidate id
- error
- a current bound approved draft is required
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/53df927a45e98afe.
Report an issue: GitHub.
Appendix: source
Thrown at ecc2/src/session/store.rs:1670
target_session_id,
task,
target_url,
task_priority_db_value(priority),
agent_type,
profile_name,
working_dir.display().to_string(),
project,
task_group,
if use_worktree { 1_i64 } else { 0_i64 },
source,
requester,
now.to_rfc3339(),
now.to_rfc3339(),
],
)?;
let id = self.conn.last_insert_rowid();
self.get_remote_dispatch_request(id)?.ok_or_else(|| {
anyhow::anyhow!("Remote dispatch request {id} was not found after insert")
})
}
pub fn list_remote_dispatch_requests(
&self,
include_processed: bool,
limit: usize,
) -> Result<Vec<RemoteDispatchRequest>> {
let sql = if include_processed {
"SELECT id, request_kind, target_session_id, task, target_url, priority, agent_type, profile_name, working_dir,
project, task_group, use_worktree, source, requester, status,
result_session_id, result_action, error, created_at, updated_at, dispatched_at
FROM remote_dispatch_requests
ORDER BY CASE status WHEN 'pending' THEN 0 WHEN 'failed' THEN 1 ELSE 2 END ASC,
priority DESC, created_at ASC, id ASC
LIMIT ?1"
} else {
"SELECT id, request_kind, target_session_id, task, target_url, priority, agent_type, profile_name, working_dir,View on GitHub (pinned to 8321021c54)