main.rs
⎇
Raw
1//! opentracker server: one binary, one SQLite file.
2
3mod auth;
4mod device;
5mod guest;
6mod passkeys;
7mod routes;
8
9use std::path::PathBuf;
10use std::sync::{Arc, Mutex, MutexGuard, PoisonError};
11use std::time::{Duration, SystemTime, UNIX_EPOCH};
12
13use axum::http::StatusCode;
14use axum::response::{IntoResponse, Response};
15use clap::{Parser, Subcommand};
16use rusqlite::{Connection, OptionalExtension, params};
17use webauthn_rs::prelude::Url;
18
19/// Schema steps, applied in order. `PRAGMA user_version` counts the applied ones.
20/// Never edit a released step. Append a new one.
21const MIGRATIONS: &[&str] = &[
22 // IF NOT EXISTS: databases from before migrations have these tables at version 0.
23 "
24CREATE TABLE IF NOT EXISTS users (
25 id INTEGER PRIMARY KEY,
26 username TEXT NOT NULL UNIQUE COLLATE NOCASE,
27 -- NULL when the account signs in with passkeys only.
28 pw_hash TEXT,
29 is_admin INTEGER NOT NULL DEFAULT 0 CHECK (is_admin IN (0, 1)),
30 two_factor INTEGER NOT NULL DEFAULT 0 CHECK (two_factor IN (0, 1)),
31 -- The WebAuthn user handle. Random, so a passkey does not reveal the user id.
32 webauthn_id TEXT NOT NULL UNIQUE,
33 retention_days INTEGER CHECK (retention_days > 0),
34 created_at INTEGER NOT NULL
35) STRICT;
36
37CREATE TABLE IF NOT EXISTS sessions (
38 token_hash BLOB PRIMARY KEY,
39 user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
40 expires_at INTEGER NOT NULL
41) STRICT;
42
43CREATE TABLE IF NOT EXISTS passkeys (
44 id INTEGER PRIMARY KEY,
45 user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
46 cred_id BLOB NOT NULL UNIQUE,
47 -- webauthn_rs::prelude::Passkey as JSON.
48 passkey TEXT NOT NULL,
49 name TEXT NOT NULL,
50 created_at INTEGER NOT NULL,
51 last_used_at INTEGER
52) STRICT;
53
54CREATE TABLE IF NOT EXISTS devices (
55 id INTEGER PRIMARY KEY,
56 user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
57 name TEXT NOT NULL,
58 token_hash BLOB NOT NULL UNIQUE,
59 created_at INTEGER NOT NULL,
60 last_seen_at INTEGER
61) STRICT;
62
63-- The key makes uploads idempotent: a retried batch collapses into the rows already there.
64CREATE TABLE IF NOT EXISTS points (
65 user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
66 ts INTEGER NOT NULL,
67 lat REAL NOT NULL,
68 lon REAL NOT NULL,
69 acc REAL,
70 alt REAL,
71 speed REAL,
72 bearing REAL,
73 battery INTEGER,
74 PRIMARY KEY (user_id, ts)
75) STRICT, WITHOUT ROWID;
76
77CREATE INDEX IF NOT EXISTS points_ts ON points(ts);
78
79CREATE TABLE IF NOT EXISTS shares (
80 id INTEGER PRIMARY KEY,
81 owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
82 viewer_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
83 expires_at INTEGER,
84 created_at INTEGER NOT NULL,
85 UNIQUE (owner_id, viewer_id),
86 CHECK (owner_id <> viewer_id)
87) STRICT;
88",
89 // Points belong to a device. The web UI uploads as one device per user, which has no token.
90 "
91CREATE TABLE devices_new (
92 id INTEGER PRIMARY KEY,
93 user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
94 name TEXT NOT NULL,
95 -- NULL for the web device.
96 token_hash BLOB UNIQUE,
97 created_at INTEGER NOT NULL,
98 last_seen_at INTEGER
99) STRICT;
100INSERT INTO devices_new SELECT * FROM devices;
101DROP TABLE devices;
102ALTER TABLE devices_new RENAME TO devices;
103CREATE UNIQUE INDEX devices_web ON devices(user_id) WHERE token_hash IS NULL;
104
105-- Older points go to the device that uploaded last, or to a new web device.
106INSERT INTO devices (user_id, name, created_at)
107SELECT DISTINCT user_id, 'Web', unixepoch() FROM points
108WHERE user_id NOT IN (SELECT user_id FROM devices);
109
110-- The key makes uploads idempotent: a retried batch collapses into the rows already there.
111CREATE TABLE points_new (
112 device_id INTEGER NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
113 ts INTEGER NOT NULL,
114 lat REAL NOT NULL,
115 lon REAL NOT NULL,
116 acc REAL,
117 alt REAL,
118 speed REAL,
119 bearing REAL,
120 battery INTEGER,
121 PRIMARY KEY (device_id, ts)
122) STRICT, WITHOUT ROWID;
123INSERT INTO points_new
124SELECT (SELECT d.id FROM devices d WHERE d.user_id = p.user_id
125 ORDER BY d.last_seen_at DESC NULLS LAST, d.id LIMIT 1),
126 ts, lat, lon, acc, alt, speed, bearing, battery
127FROM points p;
128DROP TABLE points;
129ALTER TABLE points_new RENAME TO points;
130CREATE INDEX points_ts ON points(ts);
131
132ALTER TABLE shares ADD COLUMN all_devices INTEGER NOT NULL DEFAULT 1 CHECK (all_devices IN (0, 1));
133ALTER TABLE shares ADD COLUMN trail INTEGER NOT NULL DEFAULT 1 CHECK (trail IN (0, 1));
134ALTER TABLE shares ADD COLUMN precision_m INTEGER NOT NULL DEFAULT 0 CHECK (precision_m >= 0);
135-- Used only when all_devices is 0.
136CREATE TABLE share_devices (
137 share_id INTEGER NOT NULL REFERENCES shares(id) ON DELETE CASCADE,
138 device_id INTEGER NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
139 PRIMARY KEY (share_id, device_id)
140) STRICT, WITHOUT ROWID;
141",
142 // Trails can start at a time. Guest links are shares without a viewer.
143 "
144CREATE TABLE shares_new (
145 id INTEGER PRIMARY KEY,
146 owner_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
147 -- NULL for a guest link.
148 viewer_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
149 expires_at INTEGER,
150 created_at INTEGER NOT NULL,
151 all_devices INTEGER NOT NULL DEFAULT 1 CHECK (all_devices IN (0, 1)),
152 trail INTEGER NOT NULL DEFAULT 1 CHECK (trail IN (0, 1)),
153 trail_since INTEGER,
154 precision_m INTEGER NOT NULL DEFAULT 0 CHECK (precision_m >= 0),
155 -- Guest links only. Kept readable, so the owner can copy the link again.
156 name TEXT,
157 token TEXT UNIQUE,
158 pw_hash TEXT,
159 UNIQUE (owner_id, viewer_id),
160 CHECK (owner_id <> viewer_id),
161 CHECK ((viewer_id IS NULL) = (token IS NOT NULL))
162) STRICT;
163INSERT INTO shares_new (id, owner_id, viewer_id, expires_at, created_at, all_devices, trail, precision_m)
164SELECT id, owner_id, viewer_id, expires_at, created_at, all_devices, trail, precision_m FROM shares;
165DROP TABLE shares;
166ALTER TABLE shares_new RENAME TO shares;
167",
168];
169
170/// Opens the database and brings its schema up to date.
171pub fn open(path: &std::path::Path) -> Result<Connection, Box<dyn std::error::Error>> {
172 let mut db = Connection::open(path)?;
173 db.execute_batch("PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;")?;
174 migrate(&mut db)?;
175 Ok(db)
176}
177
178fn migrate(db: &mut Connection) -> Result<(), Box<dyn std::error::Error>> {
179 let version: i64 = db.pragma_query_value(None, "user_version", |r| r.get(0))?;
180 let version = usize::try_from(version)?;
181 if version > MIGRATIONS.len() {
182 return Err(format!(
183 "the database has schema version {version}, newer than this server knows"
184 )
185 .into());
186 }
187 // Table rebuilds drop tables that others reference. SQLite ignores this pragma inside a transaction.
188 db.pragma_update(None, "foreign_keys", false)?;
189 for (i, sql) in MIGRATIONS.iter().enumerate().skip(version) {
190 let tx = db.transaction()?;
191 tx.execute_batch(sql)?;
192 let broken: bool = tx.query_row(
193 "SELECT EXISTS (SELECT 1 FROM pragma_foreign_key_check)",
194 [],
195 |r| r.get(0),
196 )?;
197 if broken {
198 return Err(format!("migration {} breaks a foreign key", i + 1).into());
199 }
200 tx.pragma_update(None, "user_version", i as i64 + 1)?;
201 tx.commit()?;
202 }
203 db.pragma_update(None, "foreign_keys", true)?;
204 Ok(())
205}
206
207#[derive(Parser)]
208#[command(about = "opentracker server")]
209struct Cli {
210 #[arg(long, env = "OT_ADDR", default_value = "127.0.0.1:8080")]
211 addr: String,
212 #[arg(long, env = "OT_DB", default_value = "ot.db")]
213 db: PathBuf,
214 /// The built web UI.
215 #[arg(long, env = "OT_WEB_DIR", default_value = "web/dist")]
216 web_dir: PathBuf,
217 /// The address browsers use, for example https://track.example.com.
218 /// Passkeys need it behind a reverse proxy. An https URL also marks the session cookie Secure.
219 #[arg(long, env = "OT_PUBLIC_URL", value_parser = parse_public_url)]
220 public_url: Option<Url>,
221 /// Days to keep points. Users can lower this for themselves. 0 keeps points forever.
222 #[arg(long, env = "OT_RETENTION_DAYS", default_value_t = 30)]
223 retention_days: i64,
224 #[command(subcommand)]
225 command: Option<Command>,
226}
227
228#[derive(Subcommand)]
229enum Command {
230 /// Create a user or reset their password. Reads the password from OT_PASSWORD or stdin.
231 ///
232 /// A reset also removes all passkeys and turns off two-factor sign-in, so a lost device cannot sign in.
233 Passwd { username: String },
234}
235
236fn parse_public_url(s: &str) -> Result<Url, String> {
237 let url = Url::parse(s).map_err(|e| e.to_string())?;
238 if !matches!(url.scheme(), "http" | "https") || url.path() != "/" {
239 return Err("must be http(s)://host[:port] without a path".into());
240 }
241 Ok(url)
242}
243
244#[derive(Clone)]
245pub struct AppState {
246 // ponytail: one connection behind a global lock. Fine for a few users; use a pool if requests queue up.
247 db: Arc<Mutex<Connection>>,
248 limiter: Arc<auth::Limiter>,
249 ceremonies: Arc<passkeys::Ceremonies>,
250 pairings: Arc<device::Pairings>,
251 public_url: Option<Url>,
252 /// 0 means forever.
253 max_retention_days: i64,
254}
255
256impl AppState {
257 pub fn db(&self) -> MutexGuard<'_, Connection> {
258 self.db.lock().unwrap_or_else(PoisonError::into_inner)
259 }
260
261 pub fn https(&self) -> bool {
262 self.public_url
263 .as_ref()
264 .is_some_and(|u| u.scheme() == "https")
265 }
266}
267
268#[derive(Debug)]
269pub enum Error {
270 BadRequest(String),
271 Unauthorized,
272 Forbidden,
273 NotFound,
274 Conflict(String),
275 TooManyRequests,
276 Internal(String),
277}
278
279impl IntoResponse for Error {
280 fn into_response(self) -> Response {
281 match self {
282 Error::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg).into_response(),
283 Error::Unauthorized => StatusCode::UNAUTHORIZED.into_response(),
284 Error::Forbidden => StatusCode::FORBIDDEN.into_response(),
285 Error::NotFound => StatusCode::NOT_FOUND.into_response(),
286 Error::Conflict(msg) => (StatusCode::CONFLICT, msg).into_response(),
287 Error::TooManyRequests => StatusCode::TOO_MANY_REQUESTS.into_response(),
288 Error::Internal(msg) => {
289 eprintln!("internal error: {msg}");
290 StatusCode::INTERNAL_SERVER_ERROR.into_response()
291 }
292 }
293 }
294}
295
296impl From<rusqlite::Error> for Error {
297 fn from(e: rusqlite::Error) -> Self {
298 Error::Internal(e.to_string())
299 }
300}
301
302pub fn now() -> i64 {
303 SystemTime::now()
304 .duration_since(UNIX_EPOCH)
305 .unwrap()
306 .as_secs() as i64
307}
308
309#[tokio::main]
310async fn main() {
311 let cli = Cli::parse();
312 let db = open(&cli.db).unwrap_or_else(|e| {
313 eprintln!("cannot open {}: {e}", cli.db.display());
314 std::process::exit(1);
315 });
316
317 match &cli.command {
318 Some(Command::Passwd { username }) => passwd(&db, username),
319 None => serve(cli, db).await,
320 }
321}
322
323/// Inserts a user. The first user ever becomes the admin.
324pub fn insert_user(
325 db: &Connection,
326 username: &str,
327 pw_hash: &str,
328 is_admin: bool,
329) -> Result<i64, Error> {
330 let first: bool = db.query_row("SELECT NOT EXISTS (SELECT 1 FROM users)", [], |r| r.get(0))?;
331 db.execute(
332 "INSERT INTO users (username, pw_hash, is_admin, webauthn_id, created_at) VALUES (?1, ?2, ?3, ?4, ?5)",
333 params![username, pw_hash, is_admin || first, uuid::Uuid::new_v4().to_string(), now()],
334 )
335 .map_err(|e| match e {
336 rusqlite::Error::SqliteFailure(f, _) if f.extended_code == rusqlite::ffi::SQLITE_CONSTRAINT_UNIQUE => {
337 Error::Conflict("that username is taken".into())
338 }
339 e => e.into(),
340 })?;
341 Ok(db.last_insert_rowid())
342}
343
344/// Sets a password and removes every other way in: passkeys, two-factor sign-in and sessions.
345/// A reset often follows a lost device, and its passkey must not keep working.
346pub fn reset_password(db: &Connection, user_id: i64, pw_hash: &str) -> rusqlite::Result<()> {
347 db.execute(
348 "UPDATE users SET pw_hash = ?1, two_factor = 0 WHERE id = ?2",
349 params![pw_hash, user_id],
350 )?;
351 db.execute("DELETE FROM passkeys WHERE user_id = ?1", [user_id])?;
352 db.execute("DELETE FROM sessions WHERE user_id = ?1", [user_id])?;
353 Ok(())
354}
355
356pub fn check_username(name: &str) -> Result<&str, Error> {
357 let name = name.trim();
358 if name.is_empty() || name.chars().count() > 64 {
359 return Err(Error::BadRequest(
360 "username must have 1 to 64 characters".into(),
361 ));
362 }
363 Ok(name)
364}
365
366fn passwd(db: &Connection, username: &str) {
367 let password = std::env::var("OT_PASSWORD").unwrap_or_else(|_| {
368 // ponytail: the password echoes on the terminal. Use rpassword if that matters.
369 eprint!("password for {username}: ");
370 let mut line = String::new();
371 std::io::stdin()
372 .read_line(&mut line)
373 .expect("read password");
374 line.trim_end_matches(['\r', '\n']).to_owned()
375 });
376 if let Err(msg) = auth::check_new_password(&password) {
377 eprintln!("{msg}");
378 std::process::exit(1);
379 }
380 let hash = auth::hash_password(&password);
381 let existing: Option<i64> = db
382 .query_row(
383 "SELECT id FROM users WHERE username = ?1",
384 [username],
385 |r| r.get(0),
386 )
387 .optional()
388 .expect("query user");
389 match existing {
390 Some(id) => {
391 reset_password(db, id, &hash).expect("update user");
392 println!("password reset for {username}, passkeys removed, two-factor sign-in off");
393 }
394 None => {
395 let username = check_username(username).unwrap_or_else(|e| {
396 eprintln!("{e:?}");
397 std::process::exit(1);
398 });
399 insert_user(db, username, &hash, false).expect("insert user");
400 println!("created user {username}");
401 }
402 }
403}
404
405async fn serve(cli: Cli, db: Connection) {
406 let state = AppState {
407 db: Arc::new(Mutex::new(db)),
408 limiter: Arc::default(),
409 ceremonies: Arc::default(),
410 pairings: Arc::default(),
411 public_url: cli.public_url,
412 max_retention_days: cli.retention_days.max(0),
413 };
414 tokio::spawn(cleanup(state.clone()));
415
416 let listener = tokio::net::TcpListener::bind(&cli.addr)
417 .await
418 .expect("bind");
419 println!(
420 "listening on http://{}, serving {}",
421 cli.addr,
422 cli.web_dir.display()
423 );
424 if state
425 .db()
426 .query_row("SELECT NOT EXISTS (SELECT 1 FROM users)", [], |r| {
427 r.get::<_, bool>(0)
428 })
429 .unwrap_or(false)
430 {
431 println!("no users yet: open the web UI to create the admin account");
432 }
433 axum::serve(listener, routes::router(state, &cli.web_dir))
434 .await
435 .expect("serve");
436}
437
438/// The days of points to keep for a user, or None for forever.
439pub fn effective_retention(user_days: Option<i64>, max_days: i64) -> Option<i64> {
440 match (user_days, max_days) {
441 (None, 0) => None,
442 (None, max) => Some(max),
443 (Some(days), 0) => Some(days),
444 (Some(days), max) => Some(days.min(max)),
445 }
446}
447
448/// Deletes points older than the user's retention. Each device keeps its newest point, so it stays on the map.
449pub fn purge_points(
450 db: &Connection,
451 user_id: i64,
452 user_days: Option<i64>,
453 max_days: i64,
454) -> rusqlite::Result<usize> {
455 match effective_retention(user_days, max_days) {
456 None => Ok(0),
457 Some(days) => db.execute(
458 "DELETE FROM points
459 WHERE device_id IN (SELECT id FROM devices WHERE user_id = ?1) AND ts < ?2
460 AND ts < (SELECT MAX(ts) FROM points p WHERE p.device_id = points.device_id)",
461 [user_id, now() - days * 86400],
462 ),
463 }
464}
465
466async fn cleanup(state: AppState) {
467 let mut tick = tokio::time::interval(Duration::from_secs(3600));
468 loop {
469 tick.tick().await;
470 let now = now();
471 let db = state.db();
472 let result = db
473 .execute_batch(&format!(
474 "DELETE FROM sessions WHERE expires_at <= {now};
475 DELETE FROM shares WHERE expires_at <= {now};"
476 ))
477 .and_then(|()| {
478 let users: Vec<(i64, Option<i64>)> = db
479 .prepare("SELECT id, retention_days FROM users")?
480 .query_map([], |r| Ok((r.get(0)?, r.get(1)?)))?
481 .collect::<rusqlite::Result<_>>()?;
482 for (id, days) in users {
483 purge_points(&db, id, days, state.max_retention_days)?;
484 }
485 Ok(())
486 });
487 if let Err(e) = result {
488 eprintln!("cleanup failed: {e}");
489 }
490 drop(db);
491 state.limiter.prune();
492 }
493}
494
495#[cfg(test)]
496pub fn test_db() -> Connection {
497 let mut db = Connection::open_in_memory().unwrap();
498 migrate(&mut db).unwrap();
499 db
500}
501
502#[cfg(test)]
503mod tests {
504 use super::*;
505
506 #[test]
507 fn retention_never_exceeds_the_server_limit() {
508 assert_eq!(effective_retention(None, 0), None);
509 assert_eq!(effective_retention(None, 30), Some(30));
510 assert_eq!(effective_retention(Some(7), 0), Some(7));
511 assert_eq!(effective_retention(Some(7), 30), Some(7));
512 assert_eq!(effective_retention(Some(90), 30), Some(30));
513 }
514
515 #[test]
516 fn public_url_is_an_origin() {
517 assert!(parse_public_url("https://track.example.com").is_ok());
518 assert!(parse_public_url("http://localhost:8080/").is_ok());
519 assert!(parse_public_url("https://example.com/track").is_err());
520 assert!(parse_public_url("ftp://example.com").is_err());
521 }
522
523 #[test]
524 fn reset_removes_every_other_way_in() {
525 let db = test_db();
526 let id = insert_user(&db, "a", "old", false).unwrap();
527 db.execute_batch(
528 "UPDATE users SET two_factor = 1;
529 INSERT INTO passkeys (user_id, cred_id, passkey, name, created_at) VALUES (1, x'01', '{}', 'k', 0);
530 INSERT INTO sessions (token_hash, user_id, expires_at) VALUES (x'02', 1, 9999999999);",
531 )
532 .unwrap();
533 reset_password(&db, id, "new").unwrap();
534 let count = |sql: &str| -> i64 { db.query_row(sql, [], |r| r.get(0)).unwrap() };
535 assert_eq!(count("SELECT COUNT(*) FROM passkeys"), 0);
536 assert_eq!(count("SELECT COUNT(*) FROM sessions"), 0);
537 assert_eq!(count("SELECT two_factor FROM users"), 0);
538 }
539
540 #[test]
541 fn migrations_keep_old_points() {
542 let mut db = Connection::open_in_memory().unwrap();
543 db.execute_batch(MIGRATIONS[0]).unwrap();
544 db.execute_batch(
545 "INSERT INTO users (id, username, webauthn_id, created_at) VALUES (1, 'a', '1', 0), (2, 'b', '2', 0);
546 INSERT INTO devices (id, user_id, name, token_hash, created_at, last_seen_at)
547 VALUES (7, 1, 'old', x'01', 0, 5), (8, 1, 'new', x'02', 0, 9);
548 INSERT INTO points (user_id, ts, lat, lon) VALUES (1, 100, 1, 1), (2, 100, 2, 2);",
549 )
550 .unwrap();
551 migrate(&mut db).unwrap();
552 migrate(&mut db).unwrap();
553 let owners: Vec<(i64, String)> = db
554 .prepare("SELECT d.user_id, d.name FROM points p JOIN devices d ON d.id = p.device_id ORDER BY d.user_id")
555 .unwrap()
556 .query_map([], |r| Ok((r.get(0)?, r.get(1)?)))
557 .unwrap()
558 .collect::<rusqlite::Result<_>>()
559 .unwrap();
560 assert_eq!(owners, [(1, "new".into()), (2, "Web".into())]);
561 }
562
563 #[test]
564 fn retention_keeps_each_devices_newest_point() {
565 let db = test_db();
566 db.execute_batch(
567 "INSERT INTO users (id, username, webauthn_id, created_at) VALUES (1, 'a', '1', 0);
568 INSERT INTO devices (id, user_id, name, token_hash, created_at) VALUES (1, 1, 'p', x'01', 0), (2, 1, 'q', x'02', 0);
569 INSERT INTO points (device_id, ts, lat, lon) VALUES (1, 10, 0, 0), (1, 20, 0, 0), (2, 15, 0, 0);",
570 )
571 .unwrap();
572 purge_points(&db, 1, Some(1), 30).unwrap();
573 let left: Vec<(i64, i64)> = db
574 .prepare("SELECT device_id, ts FROM points ORDER BY device_id")
575 .unwrap()
576 .query_map([], |r| Ok((r.get(0)?, r.get(1)?)))
577 .unwrap()
578 .collect::<rusqlite::Result<_>>()
579 .unwrap();
580 assert_eq!(left, [(1, 20), (2, 15)]);
581 }
582
583 #[test]
584 fn first_user_is_admin() {
585 let db = test_db();
586 let a = insert_user(&db, "a", "", false).unwrap();
587 let b = insert_user(&db, "b", "", false).unwrap();
588 let admin = |id: i64| -> bool {
589 db.query_row("SELECT is_admin FROM users WHERE id = ?1", [id], |r| {
590 r.get(0)
591 })
592 .unwrap()
593 };
594 assert!(admin(a));
595 assert!(!admin(b));
596 assert!(matches!(
597 insert_user(&db, "A", "", false),
598 Err(Error::Conflict(_))
599 ));
600 }
601}
602