diff --git a/bin/bedrock/src/main.rs b/bin/bedrock/src/main.rs index feb503009e..0e1718701b 100644 --- a/bin/bedrock/src/main.rs +++ b/bin/bedrock/src/main.rs @@ -39,7 +39,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .service_name(BIN_NAME) .service_namespace("si") diff --git a/bin/cyclone/src/main.rs b/bin/cyclone/src/main.rs index 49bd0fcb33..c9fb1e89a1 100644 --- a/bin/cyclone/src/main.rs +++ b/bin/cyclone/src/main.rs @@ -30,7 +30,11 @@ async fn main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/edda/src/main.rs b/bin/edda/src/main.rs index de3a24622a..40de8cc4e1 100644 --- a/bin/edda/src/main.rs +++ b/bin/edda/src/main.rs @@ -39,7 +39,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/forklift/src/main.rs b/bin/forklift/src/main.rs index d7676b5b66..8f6b59fdcb 100644 --- a/bin/forklift/src/main.rs +++ b/bin/forklift/src/main.rs @@ -39,7 +39,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/hoist/src/diff.rs b/bin/hoist/src/diff.rs index e97da30f77..ee1241e443 100644 --- a/bin/hoist/src/diff.rs +++ b/bin/hoist/src/diff.rs @@ -42,7 +42,7 @@ impl Display for PatchTarget { return Err(fmt::Error); }; - f.write_str(format!("{} socket {}", kind, name).as_str()) + f.write_str(format!("{kind} socket {name}").as_str()) } PatchTarget::SocketContents(name) => { let split_name = name.split("-").collect::>(); @@ -50,13 +50,13 @@ impl Display for PatchTarget { return Err(fmt::Error); }; - f.write_str(format!("contents of {} socket {}", kind, name).as_str()) + f.write_str(format!("contents of {kind} socket {name}").as_str()) } - PatchTarget::Prop(name) => f.write_str(format!("prop {}", name).as_str()), + PatchTarget::Prop(name) => f.write_str(format!("prop {name}").as_str()), PatchTarget::PropContents((name, target)) => { - f.write_str(format!("contents of prop {} at {}", name, target).as_str()) + f.write_str(format!("contents of prop {name} at {target}").as_str()) } - PatchTarget::Func(name) => f.write_str(format!("function {}", name).as_str()), + PatchTarget::Func(name) => f.write_str(format!("function {name}").as_str()), PatchTarget::FuncBinding(kind) => f.write_str(format!("{kind} binding").as_str()), PatchTarget::Variant => f.write_str("variant"), PatchTarget::VariantContent(path) => { diff --git a/bin/hoist/src/main.rs b/bin/hoist/src/main.rs index 26fe690faa..b04b3b1278 100644 --- a/bin/hoist/src/main.rs +++ b/bin/hoist/src/main.rs @@ -109,7 +109,7 @@ async fn main() -> Result<()> { } None => { if let Err(err) = Args::command().print_help() { - eprintln!("Error displaying help: {}", err); + eprintln!("Error displaying help: {err}"); std::process::exit(1); } std::process::exit(0); @@ -228,7 +228,7 @@ async fn write_single_spec( .iter() .find(|m| m.name == spec_name) .cloned() - .unwrap_or_else(|| panic!("Unable to find spec with name: {}", spec_name)); + .unwrap_or_else(|| panic!("Unable to find spec with name: {spec_name}")); write_spec(client, module.id, out).await } @@ -366,10 +366,7 @@ async fn diff_summaries_with_module_index( let changes_with_summary = changes_with_summary.load(Ordering::SeqCst); let hash_mismatches = hash_mismatches.load(Ordering::SeqCst); - println!( - "Total: {} new asset(s), {} changed asset(s)", - total_added, hash_mismatches - ); + println!("Total: {total_added} new asset(s), {hash_mismatches} changed asset(s)"); if changes_with_summary != hash_mismatches { println!( @@ -439,7 +436,7 @@ async fn upload_pkg_specs( let msg = format!("Parsing module: {}", spec.file_name().to_string_lossy()); pb.set_message(msg.to_string()); if non_interactive { - println!("{}", msg); + println!("{msg}"); }; let pkg = json_to_pkg(spec.path())?; @@ -458,10 +455,7 @@ async fn upload_pkg_specs( } } - println!( - "🟰 {} modules have matching hashes and will be skipped", - no_action_needed - ); + println!("🟰 {no_action_needed} modules have matching hashes and will be skipped"); println!( "🔼 {} modules exist and will be updated", modules_with_updates.len() @@ -485,12 +479,12 @@ async fn upload_pkg_specs( "p" => break, "n" => { for module in &new_modules { - println!("{}", module); + println!("{module}"); } } "u" => { for module in &modules_with_updates { - println!("{}", module); + println!("{module}"); } } @@ -505,7 +499,7 @@ async fn upload_pkg_specs( let msg = "⏰ Beginning uploads ..."; pb.set_message(msg); if non_interactive { - println!("{}", msg); + println!("{msg}"); }; // Generates the "X failed" message for various set_message() calls to use @@ -513,7 +507,7 @@ async fn upload_pkg_specs( let failed_message = || { let failed = failed.load(Ordering::Relaxed); if failed > 0 { - format!(" ❌ {} failed. ", failed) + format!(" ❌ {failed} failed. ") } else { "".to_string() } @@ -526,7 +520,7 @@ async fn upload_pkg_specs( let msg = format!("{}⏰ Uploading: {}", failed_message(), metadata.name()); pb.set_message(msg.to_string()); if non_interactive { - println!("{}", msg); + println!("{msg}"); }; pb.inc(1); async move { @@ -576,7 +570,7 @@ async fn upload_pkg_specs( ); pb.finish_with_message(msg.to_string()); if non_interactive { - println!("{}", msg); + println!("{msg}"); }; // If this message is not here, the console does not show the final message for some reason println!("Done"); diff --git a/bin/innit/src/main.rs b/bin/innit/src/main.rs index 59752bed74..f3f49a68f1 100644 --- a/bin/innit/src/main.rs +++ b/bin/innit/src/main.rs @@ -39,7 +39,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .service_name(BIN_NAME) .service_namespace("si") diff --git a/bin/innitctl/src/main.rs b/bin/innitctl/src/main.rs index ec12692678..8fd50aae1c 100644 --- a/bin/innitctl/src/main.rs +++ b/bin/innitctl/src/main.rs @@ -24,7 +24,11 @@ async fn main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .service_name(BIN_NAME) .service_namespace("si") diff --git a/bin/luminork/src/main.rs b/bin/luminork/src/main.rs index c6b4317dea..664060d499 100644 --- a/bin/luminork/src/main.rs +++ b/bin/luminork/src/main.rs @@ -51,7 +51,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/module-index/src/main.rs b/bin/module-index/src/main.rs index 6987489dbb..481f251670 100644 --- a/bin/module-index/src/main.rs +++ b/bin/module-index/src/main.rs @@ -36,7 +36,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name("module-index") diff --git a/bin/openapi-extractor/src/main.rs b/bin/openapi-extractor/src/main.rs index 078d6c03cb..46d50c1b6b 100644 --- a/bin/openapi-extractor/src/main.rs +++ b/bin/openapi-extractor/src/main.rs @@ -15,7 +15,7 @@ async fn main() -> Result<(), Box> { let api = match api_result { Ok(json_api) => json_api.0, Err((status, message)) => { - return Err(format!("API Error ({}): {}", status, message).into()); + return Err(format!("API Error ({status}): {message}").into()); } }; diff --git a/bin/pinga/src/main.rs b/bin/pinga/src/main.rs index e8fe0e4c1e..1b16a7ead3 100644 --- a/bin/pinga/src/main.rs +++ b/bin/pinga/src/main.rs @@ -41,7 +41,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/rebaser/src/main.rs b/bin/rebaser/src/main.rs index 0ffcaf418e..689789a719 100644 --- a/bin/rebaser/src/main.rs +++ b/bin/rebaser/src/main.rs @@ -41,7 +41,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/sdf/src/main.rs b/bin/sdf/src/main.rs index a3b0cd4911..672b06397f 100644 --- a/bin/sdf/src/main.rs +++ b/bin/sdf/src/main.rs @@ -55,7 +55,11 @@ async fn async_main() -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/bin/veritech/src/main.rs b/bin/veritech/src/main.rs index a6d6f4e994..7d770be4ed 100644 --- a/bin/veritech/src/main.rs +++ b/bin/veritech/src/main.rs @@ -36,7 +36,11 @@ async fn async_main(args: args::Args) -> Result<()> { let config = TelemetryConfig::builder() .force_color(args.force_color.then_some(true)) .no_color(args.no_color.then_some(true)) - .log_format(args.log_json.then_some(LogFormat::Json).unwrap_or_default()) + .log_format(if args.log_json { + LogFormat::Json + } else { + Default::default() + }) .log_file_directory(args.log_file_directory.clone()) .tokio_console(args.tokio_console) .service_name(BIN_NAME) diff --git a/flake.lock b/flake.lock index fe297fd9c0..2c040d599f 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1747312588, - "narHash": "sha256-MmJvj6mlWzeRwKGLcwmZpKaOPZ5nJb/6al5CXqJsgjo=", + "lastModified": 1752683762, + "narHash": "sha256-CVC4bpthYhKk4Qb4mt00SqfJ7CJ4vfTX06pLN2OHa1c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b1bebd0fe266bbd1820019612ead889e96a8fa2d", + "rev": "fa64ec5c1ca6f17746f3defedb988b9248e97616", "type": "github" }, "original": { @@ -34,10 +34,27 @@ "type": "github" } }, + "pinnedDenoVersion": { + "locked": { + "lastModified": 1748124733, + "narHash": "sha256-y7OLqUkEb0Leg/eZCO5/AQh1u5byAnMEj13OMIJ6Uqo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4684fd6b0c01e4b7d99027a34c93c2e09ecafee2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4684fd6b0c01e4b7d99027a34c93c2e09ecafee2", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", + "pinnedDenoVersion": "pinnedDenoVersion", "rust-overlay": "rust-overlay" } }, @@ -48,11 +65,11 @@ ] }, "locked": { - "lastModified": 1747190175, - "narHash": "sha256-s33mQ2s5L/2nyllhRTywgECNZyCqyF4MJeM3vG/GaRo=", + "lastModified": 1752720268, + "narHash": "sha256-XCiJdtXIN09Iv0i1gs5ajJ9CVHk537Gy1iG/4nIdpVI=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "58160be7abad81f6f8cb53120d5b88c16e01c06d", + "rev": "dc221f842e9ddc8c0416beae8d77f2ea356b91ae", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 529728a93f..5b7c643063 100644 --- a/flake.nix +++ b/flake.nix @@ -10,12 +10,29 @@ nixpkgs.follows = "nixpkgs"; }; }; + # NOTE 2025-07-17 + # --------------- + # + # Pin Deno to version 2.2.12 as this is the last version that successfully + # built via Hydra. All newer versions revert to source-building which takes + # way too long for every developer. + # + # When the build failures are clear and there are pre-built packages + # available for Deno again, remove this input. + # + # References: https://github.com/NixOS/nixpkgs/issues/417331 + # References: https://github.com/NixOS/nixpkgs/pull/384838 + # + # See: https://aalbacetef.io/blog/nix-pinning-a-specific-package-version-in-a-flake-using-overlays/ + # See: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=deno + pinnedDenoVersion.url = "github:NixOS/nixpkgs/4684fd6b0c01e4b7d99027a34c93c2e09ecafee2"; }; outputs = { nixpkgs, flake-utils, rust-overlay, + pinnedDenoVersion, ... }: flake-utils.lib.eachDefaultSystem (system: let @@ -24,6 +41,11 @@ nodejs = super.nodejs_20; }) (import rust-overlay) + # NOTE 2025-07-17: see inputs for explanation. When input is deleted, + # remove this overlay too. + (final: prev: { + deno = pinnedDenoVersion.legacyPackages.${prev.system}.deno; + }) ]; pkgs = import nixpkgs {inherit overlays system;}; @@ -88,7 +110,9 @@ "x86_64-darwin" = "/dev/null"; "aarch64-darwin" = "/dev/null"; } - .${system}; + .${ + system + }; # This isn't an exact science, but confirmed the system interpreter by # running `ldd /bin/sh` in Docker containers running: @@ -105,7 +129,9 @@ "x86_64-darwin" = "/dev/null"; "aarch64-darwin" = "/dev/null"; } - .${system}; + .${ + system + }; langJsExtraPkgs = with pkgs; [ awscli2 diff --git a/lib/auth-api-client/src/client.rs b/lib/auth-api-client/src/client.rs index d6e3d62cbd..1a9a3301d1 100644 --- a/lib/auth-api-client/src/client.rs +++ b/lib/auth-api-client/src/client.rs @@ -69,11 +69,8 @@ impl AuthApiClient { workspace_id: WorkspacePk, token_id: AuthTokenId, ) -> AuthApiResult { - self.get(&format!( - "workspaces/{}/authTokens/{}", - workspace_id, token_id - )) - .await + self.get(&format!("workspaces/{workspace_id}/authTokens/{token_id}")) + .await } async fn get(&self, path: &str) -> AuthApiResult { diff --git a/lib/bedrock-server/src/artifacts/mod.rs b/lib/bedrock-server/src/artifacts/mod.rs index 766909e8c1..43227f1550 100644 --- a/lib/bedrock-server/src/artifacts/mod.rs +++ b/lib/bedrock-server/src/artifacts/mod.rs @@ -127,18 +127,18 @@ pub async fn capture_nats( let base_dir = PathBuf::from("./recordings/datasources") .join(recording_id) .join("nats_sequences"); - create_dir_all(&base_dir).map_err(|e| format!("Failed to create output directory: {}", e))?; + create_dir_all(&base_dir).map_err(|e| format!("Failed to create output directory: {e}"))?; for source_stream in nats_streams { - let mirror_stream_name = format!("{}_AUDIT", source_stream); - let output_path = base_dir.join(format!("{}.sequence", source_stream)); + let mirror_stream_name = format!("{source_stream}_AUDIT"); + let output_path = base_dir.join(format!("{source_stream}.sequence")); - println!("Dumping stream: {}", mirror_stream_name); + println!("Dumping stream: {mirror_stream_name}"); let mut stream = js .get_stream(&mirror_stream_name) .await - .map_err(|e| format!("Failed to get stream {}: {}", mirror_stream_name, e))?; + .map_err(|e| format!("Failed to get stream {mirror_stream_name}: {e}"))?; let mut messages = vec![]; let mut seq = 1u64; @@ -148,11 +148,11 @@ pub async fn capture_nats( let stream_info = stream .info() .await - .map_err(|e| format!("Failed to fetch stream info: {}", e))?; + .map_err(|e| format!("Failed to fetch stream info: {e}"))?; let last_seq = stream_info.state.last_sequence; if seq > last_seq { - println!("Reached end of stream at seq {}. Ending capture.", last_seq); + println!("Reached end of stream at seq {last_seq}. Ending capture."); break; } @@ -176,13 +176,10 @@ pub async fn capture_nats( seq += 1; } Ok(Err(e)) => { - return Err(format!("Failed to get message {}: {}", seq, e)); + return Err(format!("Failed to get message {seq}: {e}")); } Err(_) => { - println!( - "Timeout waiting for message at seq {}. Ending capture.", - seq - ); + println!("Timeout waiting for message at seq {seq}. Ending capture."); break; } } @@ -190,14 +187,14 @@ pub async fn capture_nats( let mut file = TokioFile::create(&output_path) .await - .map_err(|e| format!("Failed to create output file: {}", e))?; + .map_err(|e| format!("Failed to create output file: {e}"))?; let serialized = serde_json::to_string_pretty(&messages) - .map_err(|e| format!("Failed to serialize messages: {}", e))?; + .map_err(|e| format!("Failed to serialize messages: {e}"))?; file.write_all(serialized.as_bytes()) .await - .map_err(|e| format!("Failed to write output file: {}", e))?; + .map_err(|e| format!("Failed to write output file: {e}"))?; println!( "Dumped {} messages to {}", @@ -207,9 +204,9 @@ pub async fn capture_nats( js.delete_stream(&mirror_stream_name) .await - .map_err(|e| format!("Failed to delete stream {}: {}", mirror_stream_name, e))?; + .map_err(|e| format!("Failed to delete stream {mirror_stream_name}: {e}"))?; - println!("🗑 Deleted stream {}", mirror_stream_name); + println!("🗑 Deleted stream {mirror_stream_name}"); } Ok(()) @@ -229,12 +226,12 @@ pub fn resolve_local_sql_files(recording_id: &str) -> Result, String let mut sql_paths = Vec::new(); for entry in entries { - let entry = entry.map_err(|e| format!("Failed to read entry: {}", e))?; + let entry = entry.map_err(|e| format!("Failed to read entry: {e}"))?; let path = entry.path(); if path.is_file() && path.extension().is_some_and(|e| e == "sql") { sql_paths.push( path.canonicalize() - .map_err(|e| format!("Failed to resolve absolute path: {}", e))? + .map_err(|e| format!("Failed to resolve absolute path: {e}"))? .to_string_lossy() .to_string(), ); @@ -266,11 +263,11 @@ pub async fn resolve_remote_artifact_files( .and_then(|v| v.as_str()) .ok_or_else(|| "Missing or invalid 'bucketName' in artifact config".to_string())?; - let prefix = format!("bedrock/datasources/{}/", recording_id); + let prefix = format!("bedrock/datasources/{recording_id}/"); info!("🔍 Using prefix '{}' in bucket '{}'", prefix, bucket_name); let credentials = Credentials::anonymous() - .map_err(|e| format!("Failed to get anonymous credentials: {}", e))?; + .map_err(|e| format!("Failed to get anonymous credentials: {e}"))?; let region = Region::Custom { region: "us-east-1".to_string(), @@ -278,13 +275,13 @@ pub async fn resolve_remote_artifact_files( }; let bucket = Bucket::new(bucket_name, region, credentials) - .map_err(|e| format!("Failed to create bucket: {}", e))? + .map_err(|e| format!("Failed to create bucket: {e}"))? .with_path_style(); let results = bucket .list(prefix.clone(), None) .await - .map_err(|e| format!("Failed to list objects: {}", e))?; + .map_err(|e| format!("Failed to list objects: {e}"))?; let mut all_objects = vec![]; for result in results { @@ -298,10 +295,7 @@ pub async fn resolve_remote_artifact_files( let total = all_objects.len(); if total == 0 { - return Err(format!( - "No downloadable files found under prefix {}", - prefix - )); + return Err(format!("No downloadable files found under prefix {prefix}")); } info!("Found {} files under S3 prefix '{}'", total, prefix); @@ -315,7 +309,7 @@ pub async fn resolve_remote_artifact_files( let relative_s3_path = key .strip_prefix("bedrock/datasources/") - .ok_or_else(|| format!("Unexpected object key format: {}", key))?; + .ok_or_else(|| format!("Unexpected object key format: {key}"))?; let relative_path = Path::new("recordings") .join("datasources") @@ -325,18 +319,18 @@ pub async fn resolve_remote_artifact_files( if let Some(parent) = relative_path.parent() { create_dir_all(parent) - .map_err(|e| format!("Failed to create directory {:?}: {}", parent, e))?; + .map_err(|e| format!("Failed to create directory {parent:?}: {e}"))?; } let mut file = File::create(&relative_path) .await - .map_err(|e| format!("Failed to create file {:?}: {}", relative_path, e))?; + .map_err(|e| format!("Failed to create file {relative_path:?}: {e}"))?; // Start downloading with progress tracking let mut response = bucket .get_object_stream(&key) .await - .map_err(|e| format!("Failed to fetch object {}: {}", key, e))?; + .map_err(|e| format!("Failed to fetch object {key}: {e}"))?; let total_bytes = Arc::new(AtomicUsize::new(0)); let size_bytes = obj.size as usize; @@ -357,11 +351,11 @@ pub async fn resolve_remote_artifact_files( }); while let Some(chunk) = response.bytes().next().await { - let bytes = chunk.map_err(|e| format!("Stream error: {}", e))?; + let bytes = chunk.map_err(|e| format!("Stream error: {e}"))?; total_bytes.fetch_add(bytes.len(), Ordering::Relaxed); file.write_all(&bytes) .await - .map_err(|e| format!("Failed to write chunk to file {:?}: {}", relative_path, e))?; + .map_err(|e| format!("Failed to write chunk to file {relative_path:?}: {e}"))?; } downloading.store(false, Ordering::Relaxed); @@ -389,11 +383,10 @@ pub async fn resolve_remote_artifact_files( if !found_sql && !found_sequence { return Err(format!( - "No .sql or .sequence files found under prefix {}", - prefix + "No .sql or .sequence files found under prefix {prefix}" )); } else if !found_sql { - return Err(format!("No .sql files found under prefix {}", prefix)); + return Err(format!("No .sql files found under prefix {prefix}")); } // No sequence files is totally valid for a DB restore point only, i.e. not recording. info!( @@ -412,7 +405,7 @@ pub async fn resolve_test( match resolve_local_sql_files(recording_id) { Ok(paths) => Ok(paths), Err(local_err) => { - println!("Local resolution failed: {}. Trying S3...", local_err); + println!("Local resolution failed: {local_err}. Trying S3..."); let all_paths = resolve_remote_artifact_files(recording_id, &artifact_config).await?; let sql_paths: Vec = all_paths @@ -422,8 +415,7 @@ pub async fn resolve_test( if sql_paths.is_empty() { Err(format!( - "No .sql files found remotely for recording {}", - recording_id + "No .sql files found remotely for recording {recording_id}" )) } else { println!( @@ -438,8 +430,8 @@ pub async fn resolve_test( pub async fn collect_files(recording_id: &str) -> Result, String> { fn collect_files_rec(dir: &Path, files: &mut Vec) -> Result<(), String> { - for entry in fs::read_dir(dir).map_err(|e| format!("Read dir error: {}", e))? { - let entry = entry.map_err(|e| format!("Dir entry error: {}", e))?; + for entry in fs::read_dir(dir).map_err(|e| format!("Read dir error: {e}"))? { + let entry = entry.map_err(|e| format!("Dir entry error: {e}"))?; let path = entry.path(); if path.is_dir() { collect_files_rec(&path, files)?; @@ -452,7 +444,7 @@ pub async fn collect_files(recording_id: &str) -> Result, String> { let base_path = PathBuf::from("recordings/datasources").join(recording_id); if !base_path.exists() { - return Err(format!("Path does not exist: {:?}", base_path)); + return Err(format!("Path does not exist: {base_path:?}")); } let mut file_paths = Vec::new(); @@ -468,20 +460,19 @@ pub async fn configure_nats( let js = jetstream::new(nats_client.clone()); for source_stream in nats_streams { - let mirror_stream_name = format!("{}_AUDIT", source_stream); + let mirror_stream_name = format!("{source_stream}_AUDIT"); if js.get_stream(&mirror_stream_name).await.is_ok() { - println!("🗑 Deleting existing stream: {}", mirror_stream_name); + println!("🗑 Deleting existing stream: {mirror_stream_name}"); js.delete_stream(&mirror_stream_name) .await - .map_err(|e| format!("Failed to delete stream {}: {}", mirror_stream_name, e))?; + .map_err(|e| format!("Failed to delete stream {mirror_stream_name}: {e}"))?; } let stream_config = Config { name: mirror_stream_name.clone(), description: Some(format!( - "Passive copy of {} stream for recording ID {}", - source_stream, recording_id + "Passive copy of {source_stream} stream for recording ID {recording_id}" )), storage: StorageType::File, retention: RetentionPolicy::Limits, @@ -497,10 +488,10 @@ pub async fn configure_nats( js.create_stream(stream_config.clone()) .await - .map_err(|e| format!("Failed to create stream {}: {}", mirror_stream_name, e))?; + .map_err(|e| format!("Failed to create stream {mirror_stream_name}: {e}"))?; let consumer_config = PullConsumerConfig { - durable_name: Some(format!("{}_SINK", mirror_stream_name)), + durable_name: Some(format!("{mirror_stream_name}_SINK")), deliver_policy: DeliverPolicy::All, ack_policy: AckPolicy::None, replay_policy: ReplayPolicy::Instant, @@ -510,12 +501,7 @@ pub async fn configure_nats( js.create_consumer_on_stream(consumer_config, mirror_stream_name.clone()) .await - .map_err(|e| { - format!( - "Failed to create consumer for {}: {}", - mirror_stream_name, e - ) - })?; + .map_err(|e| format!("Failed to create consumer for {mirror_stream_name}: {e}"))?; } Ok(()) @@ -542,22 +528,22 @@ pub async fn clear_nats(nats_client: &NatsClient) -> Result<(), String> { let mut names = js.stream_names(); while let Ok(Some(stream_name)) = TryStreamExt::try_next(&mut names).await { - println!("stream: {}", stream_name); + println!("stream: {stream_name}"); if stream_name.ends_with("_AUDIT") { - println!("Deleting stream: {}", stream_name); + println!("Deleting stream: {stream_name}"); js.delete_stream(&stream_name) .await - .map_err(|e| format!("Failed to delete stream {}: {}", stream_name, e))?; + .map_err(|e| format!("Failed to delete stream {stream_name}: {e}"))?; } else { - println!("Purging stream: {}", stream_name); + println!("Purging stream: {stream_name}"); let stream = js .get_stream(&stream_name) .await - .map_err(|e| format!("Failed to get stream {}: {}", stream_name, e))?; + .map_err(|e| format!("Failed to get stream {stream_name}: {e}"))?; stream .purge() .await - .map_err(|e| format!("Failed to purge stream {}: {}", stream_name, e))?; + .map_err(|e| format!("Failed to purge stream {stream_name}: {e}"))?; } } @@ -575,17 +561,17 @@ pub async fn dump_databases( { let mut file = fs::File::create(&script_path) - .map_err(|e| format!("Failed to create script file: {}", e))?; + .map_err(|e| format!("Failed to create script file: {e}"))?; file.write_all(DATABASE_DUMP_SCRIPT.as_bytes()) - .map_err(|e| format!("Failed to write script: {}", e))?; + .map_err(|e| format!("Failed to write script: {e}"))?; let mut perms = file .metadata() - .map_err(|e| format!("Failed to read metadata: {}", e))? + .map_err(|e| format!("Failed to read metadata: {e}"))? .permissions(); perms.set_mode(0o755); fs::set_permissions(&script_path, perms) - .map_err(|e| format!("Failed to set permissions: {}", e))?; + .map_err(|e| format!("Failed to set permissions: {e}"))?; } for db in databases { @@ -600,20 +586,17 @@ pub async fn dump_databases( .arg(&recording_id) .arg(&variant) .status() - .map_err(|e| format!("Failed to run script: {}", e)) + .map_err(|e| format!("Failed to run script: {e}")) .and_then(|status| { if status.success() { Ok(()) } else { - Err(format!( - "Script failed for {} with exit code: {}", - db, status - )) + Err(format!("Script failed for {db} with exit code: {status}")) } }) }) .await - .map_err(|e| format!("Join error: {}", e))??; + .map_err(|e| format!("Join error: {e}"))??; } Ok(()) @@ -626,18 +609,18 @@ pub async fn prepare_databases(sql_paths: Vec) -> Result<(), String> { { let mut file = fs::File::create(&script_path) - .map_err(|e| format!("Failed to create script file: {}", e))?; + .map_err(|e| format!("Failed to create script file: {e}"))?; file.write_all(DATABASE_PREPARE_SCRIPT.as_bytes()) - .map_err(|e| format!("Failed to write script: {}", e))?; + .map_err(|e| format!("Failed to write script: {e}"))?; let mut perms = file .metadata() - .map_err(|e| format!("Failed to read metadata: {}", e))? + .map_err(|e| format!("Failed to read metadata: {e}"))? .permissions(); perms.set_mode(0o755); fs::set_permissions(&script_path, perms) - .map_err(|e| format!("Failed to set permissions: {}", e))?; + .map_err(|e| format!("Failed to set permissions: {e}"))?; } // Spawn a task for each SQL file to be restored @@ -646,17 +629,17 @@ pub async fn prepare_databases(sql_paths: Vec) -> Result<(), String> { let file_name = path .file_name() .and_then(|f| f.to_str()) - .ok_or_else(|| format!("Invalid file name in path: {}", sql_path))?; + .ok_or_else(|| format!("Invalid file name in path: {sql_path}"))?; let database_name = if file_name == "globals.sql" { "postgres".to_string() } else if file_name.ends_with("public_schema.sql") { file_name .strip_suffix("_public_schema.sql") - .ok_or_else(|| format!("Invalid public_schema filename: {}", file_name))? + .ok_or_else(|| format!("Invalid public_schema filename: {file_name}"))? .to_string() } else { - return Err(format!("Unknown SQL filename pattern: {}", file_name)); + return Err(format!("Unknown SQL filename pattern: {file_name}")); }; let script_path = script_path.clone(); @@ -669,20 +652,19 @@ pub async fn prepare_databases(sql_paths: Vec) -> Result<(), String> { .stdout(Stdio::null()) // suppress stdout as it's super chatty .stderr(Stdio::inherit()) .status() - .map_err(|e| format!("Failed to run script: {}", e)) + .map_err(|e| format!("Failed to run script: {e}")) .and_then(|status| { if status.success() { Ok(()) } else { Err(format!( - "Script failed for {} with exit code: {}", - sql_path, status + "Script failed for {sql_path} with exit code: {status}" )) } }) }) .await - .map_err(|e| format!("Join error: {}", e))??; + .map_err(|e| format!("Join error: {e}"))??; } Ok(()) @@ -708,8 +690,7 @@ pub async fn publish_artifact( if access_key_empty || secret_key_empty { return Err(format!( - "Credentials are required to publish to the artifact store: {}", - artifact_id + "Credentials are required to publish to the artifact store: {artifact_id}" )); } @@ -721,7 +702,7 @@ pub async fn publish_artifact( .build(); let client = Client::from_conf(config); - let s3_prefix = format!("bedrock/datasources/{}/", artifact_id); + let s3_prefix = format!("bedrock/datasources/{artifact_id}/"); let existing = client .list_objects_v2() @@ -729,21 +710,17 @@ pub async fn publish_artifact( .prefix(&s3_prefix) .send() .await - .map_err(|e| format!("Failed to list objects: {}", e))?; + .map_err(|e| format!("Failed to list objects: {e}"))?; if existing.key_count().unwrap_or(0) > 0 { return Err(format!( - "Test '{}' already exists. Please re-identify and retry.", - artifact_id + "Test '{artifact_id}' already exists. Please re-identify and retry." )); } let base_path = PathBuf::from("recordings/datasources").join(artifact_id); if !base_path.exists() { - return Err(format!( - "Local artifact path does not exist: {:?}", - base_path - )); + return Err(format!("Local artifact path does not exist: {base_path:?}")); } let file_paths: Vec = collect_files(artifact_id).await?; @@ -755,7 +732,7 @@ pub async fn publish_artifact( .to_string_lossy() .replace('\\', "/"); - let s3_key = format!("bedrock/datasources/{}", key); + let s3_key = format!("bedrock/datasources/{key}"); let total = file_paths.len(); let artifact_index = index + 1; @@ -766,7 +743,7 @@ pub async fn publish_artifact( let file = TokioFile::open(&path) .await - .map_err(|e| format!("Failed to open file {:?}: {}", path, e))?; + .map_err(|e| format!("Failed to open file {path:?}: {e}"))?; let metadata = file.metadata().await.map_err(|e| e.to_string())?; let size_bytes = metadata.len() as usize; @@ -813,7 +790,7 @@ pub async fn publish_artifact( .body(ByteStream::from(buffer)) .send() .await - .map_err(|e| format!("Upload failed: {}", e))?; + .map_err(|e| format!("Upload failed: {e}"))?; let bar = progress_bar_line(1.0, artifact_index, total); info!("{}", bar); diff --git a/lib/bedrock-server/src/profiles/rebaser/measure_rebase.rs b/lib/bedrock-server/src/profiles/rebaser/measure_rebase.rs index 5575e3d15d..91f30d5867 100644 --- a/lib/bedrock-server/src/profiles/rebaser/measure_rebase.rs +++ b/lib/bedrock-server/src/profiles/rebaser/measure_rebase.rs @@ -52,7 +52,7 @@ fn load_message_sequence(recording_id: &str) -> Vec { let mut other_messages = Vec::new(); for entry in entries { - let entry = entry.unwrap_or_else(|e| panic!("Failed to read entry: {}", e)); + let entry = entry.unwrap_or_else(|e| panic!("Failed to read entry: {e}")); let path = entry.path(); if path.is_file() { @@ -98,7 +98,7 @@ pub async fn reissue_rebaser_tracker_message( workspace_id: &str, changeset_id: &str, ) -> Result<(), String> { - let subject = format!("rebaser.tasks.{}.{}.process", workspace_id, changeset_id); + let subject = format!("rebaser.tasks.{workspace_id}.{changeset_id}.process"); let js = jetstream::new(nats.clone()); let headers = HeaderMap::new(); @@ -155,7 +155,7 @@ impl TestProfile for MeasureRebase { let mut success_count = 0; for (i, json_msg) in messages.into_iter().enumerate() { - let reply_subject = format!("_INBOX.INCOMING_RESPONSES.{}", i); + let reply_subject = format!("_INBOX.INCOMING_RESPONSES.{i}"); let mut headers = HeaderMap::new(); let new_ulid = Ulid::new().to_string(); @@ -233,10 +233,10 @@ impl TestProfile for MeasureRebase { let response = tokio::select! { msg = sub.next() => msg, _ = &mut timeout => { - println!("Timeout waiting for response on {}", reply_subject); + println!("Timeout waiting for response on {reply_subject}"); return TestResult { success: false, - message: format!("Timeout waiting for response from service on subject {}", reply_subject), + message: format!("Timeout waiting for response from service on subject {reply_subject}"), duration_ms: None, output: Some(json!({ "failed_message_index": i, @@ -270,15 +270,11 @@ impl TestProfile for MeasureRebase { .and_then(|err| err.get("message")) .and_then(|msg| msg.as_str()) { - println!( - "Early exit: error in response: {}", - error_msg - ); + println!("Early exit: error in response: {error_msg}"); return TestResult { success: false, message: format!( - "Error at message {}: {}", - i, error_msg + "Error at message {i}: {error_msg}" ), duration_ms: None, output: Some(json!({ @@ -289,11 +285,11 @@ impl TestProfile for MeasureRebase { } } Err(e) => { - println!("Failed to parse response CBOR: {:?}", e); + println!("Failed to parse response CBOR: {e:?}"); } } } - None => println!("No response received on {}", reply_subject), + None => println!("No response received on {reply_subject}"), } } Err(e) => println!("Ack error for {}: {:?}", json_msg.subject, e), @@ -304,7 +300,7 @@ impl TestProfile for MeasureRebase { TestResult { success: true, - message: format!("Sent and received {} message-response pairs", success_count), + message: format!("Sent and received {success_count} message-response pairs"), duration_ms: Some(42), output: Some(json!({ "message_response_pairs": success_count })), } diff --git a/lib/bedrock-server/src/routes/prepare.rs b/lib/bedrock-server/src/routes/prepare.rs index 6d882c8705..3f957afdee 100644 --- a/lib/bedrock-server/src/routes/prepare.rs +++ b/lib/bedrock-server/src/routes/prepare.rs @@ -51,7 +51,7 @@ pub async fn prepare_route( if let Err(e) = prepare_databases(database_sql_dumps).await { let result = PrepareResult { success: false, - message: format!("Failed to prepare requested databases: {}", e), + message: format!("Failed to prepare requested databases: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, @@ -62,7 +62,7 @@ pub async fn prepare_route( if let Err(e) = clear_nats(&state.nats).await { let result = PrepareResult { success: false, - message: format!("Failed to clear nats: {}", e), + message: format!("Failed to clear nats: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, @@ -81,7 +81,7 @@ pub async fn prepare_route( Err(e) => { let result = PrepareResult { success: false, - message: format!("Failed to collect files: {}", e), + message: format!("Failed to collect files: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, diff --git a/lib/bedrock-server/src/routes/record.rs b/lib/bedrock-server/src/routes/record.rs index 5ab84b0ee6..1b313eeeea 100644 --- a/lib/bedrock-server/src/routes/record.rs +++ b/lib/bedrock-server/src/routes/record.rs @@ -41,7 +41,7 @@ pub async fn start_recording_route( if let Err(e) = configure_nats(&state.nats, nats_streams, &recording_id).await { let result = RecordResult { success: false, - message: format!("Failed to setup nats: {}", e), + message: format!("Failed to setup nats: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, @@ -55,7 +55,7 @@ pub async fn start_recording_route( if let Err(e) = dump_databases(postgres_dbs, &recording_id, "start").await { let result = RecordResult { success: false, - message: format!("Failed to dump requested databases: {}", e), + message: format!("Failed to dump requested databases: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, @@ -103,7 +103,7 @@ pub async fn stop_recording_route( if let Err(e) = capture_nats(&state.nats, nats_streams, &recording_id).await { let result = RecordResult { success: false, - message: format!("Failed to capture messages on nats: {}", e), + message: format!("Failed to capture messages on nats: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, @@ -117,7 +117,7 @@ pub async fn stop_recording_route( if let Err(e) = dump_databases(postgres_dbs, &recording_id, "end").await { let result = RecordResult { success: false, - message: format!("Failed to dump requested databases: {}", e), + message: format!("Failed to dump requested databases: {e}"), recording_id, duration_ms: Some(start_time.elapsed().as_millis() as u64), output: None, @@ -135,8 +135,7 @@ pub async fn stop_recording_route( let response = RecordResult { success: true, message: format!( - "Recording stopped, please see output directory for content for recording_id {}", - recording_id + "Recording stopped, please see output directory for content for recording_id {recording_id}" ), recording_id, duration_ms: Some(duration), diff --git a/lib/bedrock-server/src/server.rs b/lib/bedrock-server/src/server.rs index ff204601b5..4e81d8b5ed 100644 --- a/lib/bedrock-server/src/server.rs +++ b/lib/bedrock-server/src/server.rs @@ -162,7 +162,7 @@ pub fn build_service( tracing::error!(error = %err, "Unexpected error in request processing"); Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) - .body(format!("Internal server error: {}", err)) + .body(format!("Internal server error: {err}")) .expect("Unable to build error response body") .into_response() })) diff --git a/lib/config-file/src/parameter_provider.rs b/lib/config-file/src/parameter_provider.rs index 6b13459d5b..af61bb00ab 100644 --- a/lib/config-file/src/parameter_provider.rs +++ b/lib/config-file/src/parameter_provider.rs @@ -61,7 +61,7 @@ impl ParameterSource

{ builder: ConfigBuilder, ) -> Result, config::ConfigError> { let environment = self.provider.environment().await; - let global_path = format!("si/{}/global", environment); + let global_path = format!("si/{environment}/global"); let global_params = match self .provider .get_parameters_by_path(global_path.clone()) diff --git a/lib/cyclone-client/src/client.rs b/lib/cyclone-client/src/client.rs index 8308d8ea47..1d8095e66d 100644 --- a/lib/cyclone-client/src/client.rs +++ b/lib/cyclone-client/src/client.rs @@ -118,7 +118,7 @@ pub enum ClientError { #[error("failed to resolve socket addrs")] SocketAddrResolve(#[source] std::io::Error), #[error("failed to create a tungstenite http request")] - TungsteniteRequest(#[source] tokio_tungstenite::tungstenite::Error), + TungsteniteRequest(#[source] Box), #[error("unexpected status code: {0}")] UnexpectedStatusCode(StatusCode), #[error("client is not healthy")] @@ -126,7 +126,7 @@ pub enum ClientError { #[error("failed to decode as a UTF8 string")] Utf8Decode(#[from] std::str::Utf8Error), #[error("failed to establish a websocket connection")] - WebsocketConnection(#[source] tokio_tungstenite::tungstenite::Error), + WebsocketConnection(#[source] Box), } impl ClientError { @@ -372,7 +372,7 @@ where let mut request = uri .into_client_request() - .map_err(ClientError::TungsteniteRequest)?; + .map_err(|err| ClientError::TungsteniteRequest(Box::new(err)))?; propagation::inject_headers(request.headers_mut()); Ok(request) @@ -455,9 +455,10 @@ where let stream = self.connect().await?; let request = self.new_ws_request(path_and_query)?; - let (websocket_stream, response) = tokio_tungstenite::client_async(request, stream) - .await - .map_err(ClientError::WebsocketConnection)?; + let (websocket_stream, response) = + tokio_tungstenite::client_async(request, stream) + .await + .map_err(|err| ClientError::WebsocketConnection(Box::new(err)))?; if response.status() != StatusCode::SWITCHING_PROTOCOLS { return Err(ClientError::UnexpectedStatusCode(response.status())); } diff --git a/lib/dal-test/src/expand_helpers.rs b/lib/dal-test/src/expand_helpers.rs index 1ef5f1cd4c..2f9221968b 100644 --- a/lib/dal-test/src/expand_helpers.rs +++ b/lib/dal-test/src/expand_helpers.rs @@ -116,15 +116,14 @@ fn tracing_init_inner(span_events_env_var: &str, log_env_var: &str) { "active" => FmtSpan::ACTIVE, "full" => FmtSpan::FULL, _ => panic!( - "{} must contain filters separated by `,`.\n\t\ + "{span_events_env_var} must contain filters separated by `,`.\n\t\ For example: `active` or `new,close`\n\t - Got: {}", - span_events_env_var, value, + Got: {value}", ), }) .fold(FmtSpan::NONE, |acc, filter| filter | acc), Err(::std::env::VarError::NotUnicode(_)) => { - panic!("{} must contain a valid UTF-8 string", span_events_env_var,) + panic!("{span_events_env_var} must contain a valid UTF-8 string",) } Err(::std::env::VarError::NotPresent) => FmtSpan::NONE, } diff --git a/lib/dal/examples/rebase/main.rs b/lib/dal/examples/rebase/main.rs index fda75bd9ff..40218f6717 100644 --- a/lib/dal/examples/rebase/main.rs +++ b/lib/dal/examples/rebase/main.rs @@ -34,7 +34,7 @@ type Result = std::result::Result>; const USAGE: &str = "usage: cargo run --example rebase "; fn load_serialized_stuff(path: &str) -> Result { - println!("opening file: {}", path); + println!("opening file: {path}"); let mut file = File::open(path)?; let mut bytes = vec![]; file.read_to_end(&mut bytes)?; @@ -70,7 +70,7 @@ fn main() -> Result<()> { graph_to_update.perform_updates(&updates); if let Err(Cycle(node_id)) = toposort(&graph_to_update) { - println!("Cycle detected at node ID: {}", node_id); + println!("Cycle detected at node ID: {node_id}"); // dbg!( // graph_to_update // .raw_nodes() diff --git a/lib/dal/examples/snapshot-surfer/main.rs b/lib/dal/examples/snapshot-surfer/main.rs index a2c630e2e8..5a7ccbfe4e 100644 --- a/lib/dal/examples/snapshot-surfer/main.rs +++ b/lib/dal/examples/snapshot-surfer/main.rs @@ -57,7 +57,7 @@ async fn main() -> Result<()> { let ident = node_ident(&graph, node_idx)?; println!(); println!("{}", "=".repeat(ident.len())); - println!("{}", ident); + println!("{ident}"); println!(); println!(" {:?}", graph.get_node_weight(node_idx)?); print_edges(&graph, node_idx)?; @@ -87,7 +87,7 @@ fn print_edges(graph: &WorkspaceSnapshotGraph, index: NodeIndex) -> Result<()> { .try_collect()?; println!(); for incoming in incoming { - println!(" {}", incoming); + println!(" {incoming}"); } println!(); @@ -99,7 +99,7 @@ fn print_edges(graph: &WorkspaceSnapshotGraph, index: NodeIndex) -> Result<()> { }) .try_collect()?; for outgoing in outgoing { - println!(" {}", outgoing); + println!(" {outgoing}"); } Ok(()) } diff --git a/lib/dal/src/action.rs b/lib/dal/src/action.rs index e38c98436c..3391f786da 100644 --- a/lib/dal/src/action.rs +++ b/lib/dal/src/action.rs @@ -76,43 +76,127 @@ pub mod prototype; #[derive(Debug, Error)] pub enum ActionError { #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] crate::attribute::prototype::AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] AttributePrototypeArgument( - #[from] crate::attribute::prototype::argument::AttributePrototypeArgumentError, + #[from] Box, ), #[error("AttributeValue error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("Change Set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("Component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("component not found for action: {0}")] ComponentNotFoundForAction(ActionId), #[error("dependent value root error: {0}")] - DependentValueRoot(#[from] DependentValueRootError), + DependentValueRoot(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("Helper error: {0}")] - Helper(#[from] HelperError), + Helper(#[from] Box), #[error("InferredConnectionGraph error: {0}")] - InferredConnectionGraph(#[from] InferredConnectionGraphError), + InferredConnectionGraph(#[from] Box), #[error("Layer DB error: {0}")] LayerDb(#[from] LayerDbError), #[error("Node Weight error: {0}")] - NodeWeight(#[from] NodeWeightError), + NodeWeight(#[from] Box), #[error("prototype not found for action: {0}")] PrototypeNotFoundForAction(ActionId), #[error("Transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("Unable to determine kind for action: {0}")] UnableToGetKind(ActionId), #[error("Workspace Snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for ActionError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: crate::attribute::prototype::AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: crate::attribute::prototype::argument::AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: DependentValueRootError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: HelperError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: InferredConnectionGraphError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } pub type ActionResult = Result; diff --git a/lib/dal/src/action/prototype.rs b/lib/dal/src/action/prototype.rs index ace84f0d24..fb7fad71ef 100644 --- a/lib/dal/src/action/prototype.rs +++ b/lib/dal/src/action/prototype.rs @@ -71,37 +71,103 @@ pub enum ActionPrototypeError { #[error("action error: {0}")] Action(#[from] Box), #[error("Change Set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("diagram error: {0}")] - Diagram(#[from] DiagramError), + Diagram(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func not found for prototype: {0}")] FuncNotFoundForPrototype(ActionPrototypeId), #[error("func runner error: {0}")] - FuncRunner(#[from] FuncRunnerError), + FuncRunner(#[from] Box), #[error("func runner has failed to send a value and exited")] FuncRunnerSend, #[error("Helper error: {0}")] - Helper(#[from] HelperError), + Helper(#[from] Box), #[error("Layer DB Error: {0}")] LayerDb(#[from] LayerDbError), #[error("Node Weight error: {0}")] - NodeWeight(#[from] NodeWeightError), + NodeWeight(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant not found for prototype: {0}")] SchemaVariantNotFoundForPrototype(ActionPrototypeId), #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("Transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("Workspace Snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for ActionPrototypeError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: DiagramError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: FuncRunnerError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: HelperError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for ActionPrototypeError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } pub type ActionPrototypeResult = Result; diff --git a/lib/dal/src/attribute/path.rs b/lib/dal/src/attribute/path.rs index 968b1430fd..b96b229a3b 100644 --- a/lib/dal/src/attribute/path.rs +++ b/lib/dal/src/attribute/path.rs @@ -32,7 +32,7 @@ pub enum AttributePath { impl std::fmt::Display for AttributePath { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - AttributePath::JsonPointer(path) => write!(f, "{}", path), + AttributePath::JsonPointer(path) => write!(f, "{path}"), } } } diff --git a/lib/dal/src/attribute/prototype.rs b/lib/dal/src/attribute/prototype.rs index 629884b3e3..8938305be0 100644 --- a/lib/dal/src/attribute/prototype.rs +++ b/lib/dal/src/attribute/prototype.rs @@ -97,13 +97,13 @@ pub enum AttributePrototypeError { #[error("attribute value error: {0}")] AttributeValue(#[from] Box), #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func error: {0}")] - FuncArgument(#[from] crate::func::argument::FuncArgumentError), + FuncArgument(#[from] Box), #[error("helper error: {0}")] - Helper(#[from] HelperError), + Helper(#[from] Box), #[error("layer db error: {0}")] LayerDb(#[from] LayerDbError), #[error("attribute prototype {0} is missing a function edge")] @@ -142,6 +142,30 @@ impl From for AttributePrototypeError { } } +impl From for AttributePrototypeError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeError { + fn from(value: crate::func::argument::FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeError { + fn from(value: HelperError) -> Self { + Box::new(value).into() + } +} + /// Indicates the _one and only one_ eventual parent of a corresponding [`AttributePrototype`]. /// /// - If an [`AttributePrototype`] is used by an [`AttributeValue`], its eventual parent is a diff --git a/lib/dal/src/attribute/prototype/debug.rs b/lib/dal/src/attribute/prototype/debug.rs index cad277a085..a5f61ad557 100644 --- a/lib/dal/src/attribute/prototype/debug.rs +++ b/lib/dal/src/attribute/prototype/debug.rs @@ -61,33 +61,33 @@ type AttributePrototypeDebugViewResult = Result), #[error("attribute prototype error: {0}")] - AttributePrototypeError(#[from] AttributePrototypeError), + AttributePrototypeError(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("component error: {0}")] - ComponentError(#[from] ComponentError), + ComponentError(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgumentError(#[from] FuncArgumentError), + FuncArgumentError(#[from] Box), #[error("input socket error: {0}")] - InputSocketError(#[from] InputSocketError), + InputSocketError(#[from] Box), #[error("node weight error: {0}")] - NodeWeightError(#[from] NodeWeightError), + NodeWeightError(#[from] Box), #[error("output socket error: {0}")] - OutputSocketError(#[from] OutputSocketError), + OutputSocketError(#[from] Box), #[error("prop error: {0}")] - PropError(#[from] PropError), + PropError(#[from] Box), #[error("secret error: {0}")] - SecretError(#[from] SecretError), + SecretError(#[from] Box), #[error("serde json error: {0}")] SerdeJsonError(#[from] serde_json::Error), #[error("value source error: {0}")] - ValueSourceError(#[from] ValueSourceError), + ValueSourceError(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshotError(#[from] WorkspaceSnapshotError), + WorkspaceSnapshotError(#[from] Box), } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -176,7 +176,7 @@ impl AttributePrototypeDebugView { vec![FuncArgDebugView { value: view.unwrap_or(Value::Null), name: func_arg_name.clone(), - value_source: format!("{:?}", value_source), + value_source: format!("{value_source:?}"), value_source_id, path: None, socket_source_kind: None, @@ -189,7 +189,7 @@ impl AttributePrototypeDebugView { "[REDACTED KEY FOR SECRET (ID: {secret_id})]" ))?, name: func_arg_name.clone(), - value_source: format!("{:?}", value_source), + value_source: format!("{value_source:?}"), value_source_id: secret_id.into(), path: None, socket_source_kind: None, @@ -203,7 +203,7 @@ impl AttributePrototypeDebugView { vec![FuncArgDebugView { value: val, name: func_arg_name.clone(), - value_source: format!("{:?}", value_source), + value_source: format!("{value_source:?}"), value_source_id: static_argument_value_id.into(), path: None, socket_source_kind: None, @@ -225,7 +225,7 @@ impl AttributePrototypeDebugView { let func_arg_debug = FuncArgDebugView { value: view, name: func_arg_name.clone(), - value_source: format!("{:?}", value_source), + value_source: format!("{value_source:?}"), value_source_id: prop_id.into(), socket_source_kind: None, path: prop_path, @@ -252,7 +252,7 @@ impl AttributePrototypeDebugView { let func_arg_debug = FuncArgDebugView { value: value_view, name: func_arg_name.clone(), - value_source: format!("{:?}", value_source), + value_source: format!("{value_source:?}"), value_source_id: input_socket_id.into(), socket_source_kind: Some(SocketSourceKind::Manual), path: attribute_value_path, @@ -279,7 +279,7 @@ impl AttributePrototypeDebugView { let func_arg_debug = FuncArgDebugView { value: value_view, name: func_arg_name.clone(), - value_source: format!("{:?}", value_source), + value_source: format!("{value_source:?}"), value_source_id: output_socket_id.into(), socket_source_kind: Some(SocketSourceKind::Manual), path: attribute_value_path, @@ -360,3 +360,81 @@ impl AttributePrototypeDebugView { Ok(view) } } + +impl From for AttributePrototypeDebugViewError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: SecretError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: ValueSourceError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributePrototypeDebugViewError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/attribute/value.rs b/lib/dal/src/attribute/value.rs index 99fe554768..72a4531875 100644 --- a/lib/dal/src/attribute/value.rs +++ b/lib/dal/src/attribute/value.rs @@ -131,9 +131,9 @@ pub enum AttributeValueError { #[error("action error: {0}")] Action(String), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error( "attribute prototype argument {0} has a value source {1:?} but no value for that prop found in component {2}" )] @@ -192,9 +192,9 @@ pub enum AttributeValueError { #[error("object field is not a child prop of the object prop: {0}")] FieldNotChildOfObject(AttributeValueId), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("function result failure: kind={kind}, message={message}, backend={backend}")] FuncBackendResultFailure { kind: String, @@ -212,7 +212,7 @@ pub enum AttributeValueError { #[error("InferredConnectionGraph error: {0}")] InferredConnectionGraph(#[from] InferredConnectionGraphError), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("cannot insert for prop kind: {0}")] InsertionForInvalidPropKind(PropKind), #[error("jsonptr parse error parsing {0}: {1}")] @@ -252,11 +252,11 @@ pub enum AttributeValueError { #[error("attribute value {0} has no outgoing edge to a prop or socket")] OrphanedAttributeValue(AttributeValueId), #[error("output socket error: {0}")] - OutputSocketError(#[from] OutputSocketError), + OutputSocketError(#[from] Box), #[error("parent prop of map or array not found: {0}")] ParentAttributeValueMissing(AttributeValueId), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("array or map prop missing element prop: {0}")] PropMissingElementProp(PropId), #[error("array or map prop has more than one child prop: {0}")] @@ -286,9 +286,9 @@ pub enum AttributeValueError { #[error("reached unreachable code")] Unreachable, #[error("validation error: {0}")] - Validation(#[from] ValidationError), + Validation(#[from] Box), #[error("value source error: {0}")] - ValueSource(#[from] ValueSourceError), + ValueSource(#[from] Box), #[error("workspace error: {0}")] Workspace(String), #[error("workspace snapshot error: {0}")] @@ -313,6 +313,60 @@ impl From for AttributeValueError { } } +impl From for AttributeValueError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: ValidationError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeValueError { + fn from(value: ValueSourceError) -> Self { + Box::new(value).into() + } +} + pub type AttributeValueResult = Result; pub use si_id::AttributeValueId; diff --git a/lib/dal/src/attribute/value/debug.rs b/lib/dal/src/attribute/value/debug.rs index a0356c803f..1db935faa7 100644 --- a/lib/dal/src/attribute/value/debug.rs +++ b/lib/dal/src/attribute/value/debug.rs @@ -69,29 +69,29 @@ type AttributeDebugViewResult = Result; #[derive(Error, Debug)] pub enum AttributeDebugViewError { #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgumentError(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgumentError(#[from] Box), #[error("attribute debug view error: {0}")] - AttributePrototypeDebugViewError(#[from] AttributePrototypeDebugViewError), + AttributePrototypeDebugViewError(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototypeError(#[from] AttributePrototypeError), + AttributePrototypeError(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("component error: {0}")] - ComponentError(#[from] ComponentError), + ComponentError(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("input socket error: {0}")] - InputSocketError(#[from] InputSocketError), + InputSocketError(#[from] Box), #[error("node weight error: {0}")] - NodeWeightError(#[from] NodeWeightError), + NodeWeightError(#[from] Box), #[error("output socket error: {0}")] - OutputSocketError(#[from] OutputSocketError), + OutputSocketError(#[from] Box), #[error("prop error: {0}")] - PropError(#[from] PropError), + PropError(#[from] Box), #[error("value source error: {0}")] - ValueSourceError(#[from] ValueSourceError), + ValueSourceError(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshotError(#[from] WorkspaceSnapshotError), + WorkspaceSnapshotError(#[from] Box), } impl AttributeDebugView { #[instrument(level = "trace", skip_all)] @@ -139,3 +139,75 @@ impl AttributeDebugView { Ok(view) } } + +impl From for AttributeDebugViewError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: AttributePrototypeDebugViewError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: ValueSourceError) -> Self { + Box::new(value).into() + } +} + +impl From for AttributeDebugViewError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/attribute/value/dependent_value_graph.rs b/lib/dal/src/attribute/value/dependent_value_graph.rs index 3c1816737c..4565440fc1 100644 --- a/lib/dal/src/attribute/value/dependent_value_graph.rs +++ b/lib/dal/src/attribute/value/dependent_value_graph.rs @@ -554,10 +554,7 @@ impl DependentValueGraph { .map(ToOwned::to_owned) .expect("component name exists for every value"); - format!( - "label = \"{}\n{}\n{}\"", - component_name, attribute_value_id, is_for_string - ) + format!("label = \"{component_name}\n{attribute_value_id}\n{is_for_string}\"") }; let dot = petgraph::dot::Dot::with_attr_getters( diff --git a/lib/dal/src/audit_logging.rs b/lib/dal/src/audit_logging.rs index a290102f84..0e09beda55 100644 --- a/lib/dal/src/audit_logging.rs +++ b/lib/dal/src/audit_logging.rs @@ -81,7 +81,11 @@ pub(crate) async fn publish_pending( // TODO(nick): nuke this from intergalactic orbit. Then do it again. let workspace_id = match ctx.workspace_pk() { Ok(workspace_id) => workspace_id, - Err(TransactionsError::SiDb(si_db::Error::NoWorkspace)) => return Ok(()), + Err(TransactionsError::SiDb(si_db_err)) + if matches!(si_db_err.as_ref(), si_db::Error::NoWorkspace) => + { + return Ok(()); + } Err(err) => return Err(AuditLoggingError::Transactions(Box::new(err))), }; @@ -217,7 +221,11 @@ pub(crate) async fn write( // TODO(nick): nuke this from intergalactic orbit. Then do it again. let workspace_id = match ctx.workspace_pk() { Ok(workspace_id) => workspace_id, - Err(TransactionsError::SiDb(si_db::Error::NoWorkspace)) => return Ok(()), + Err(TransactionsError::SiDb(si_db_err)) + if matches!(si_db_err.as_ref(), si_db::Error::NoWorkspace) => + { + return Ok(()); + } Err(err) => return Err(AuditLoggingError::Transactions(Box::new(err))), }; @@ -248,7 +256,11 @@ pub(crate) async fn write_final_message(ctx: &DalContext) -> Result<()> { // TODO(nick): nuke this from intergalactic orbit. Then do it again. let workspace_id = match ctx.workspace_pk() { Ok(workspace_id) => workspace_id, - Err(TransactionsError::SiDb(si_db::Error::NoWorkspace)) => return Ok(()), + Err(TransactionsError::SiDb(si_db_err)) + if matches!(si_db_err.as_ref(), si_db::Error::NoWorkspace) => + { + return Ok(()); + } Err(err) => return Err(AuditLoggingError::Transactions(Box::new(err))), }; diff --git a/lib/dal/src/builtins.rs b/lib/dal/src/builtins.rs index fe5c11b8b9..7000e2bdad 100644 --- a/lib/dal/src/builtins.rs +++ b/lib/dal/src/builtins.rs @@ -32,15 +32,15 @@ pub mod schema; #[derive(Error, Debug)] pub enum BuiltinsError { #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("attribute value not found by id: {0}")] AttributeValueNotFound(AttributeValueId), #[error("builtin {0} missing func argument {1}")] BuiltinMissingFuncArgument(String, String), #[error("func error")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("json error {1} at file {0}")] FuncJson(String, serde_json::Error), #[error("func metadata error: {0}")] @@ -54,9 +54,9 @@ pub enum BuiltinsError { #[error("no packages path configured")] MissingPkgsPath, #[error("module error: {0}")] - Module(#[from] ModuleError), + Module(#[from] Box), #[error("pkg error: {0}")] - Pkg(#[from] PkgError), + Pkg(#[from] Box), #[error("prop cache not found: {0}")] PropCacheNotFound(SchemaVariantId), #[error("prop not bound by id: {0}")] @@ -64,7 +64,7 @@ pub enum BuiltinsError { #[error("regex parsing error: {0}")] Regex(#[from] regex::Error), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("encountered serde json error for func ({0}): {1}")] @@ -77,4 +77,40 @@ pub enum BuiltinsError { Transactions(#[from] TransactionsError), } +impl From for BuiltinsError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for BuiltinsError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for BuiltinsError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for BuiltinsError { + fn from(value: ModuleError) -> Self { + Box::new(value).into() + } +} + +impl From for BuiltinsError { + fn from(value: PkgError) -> Self { + Box::new(value).into() + } +} + +impl From for BuiltinsError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + pub type BuiltinsResult = Result; diff --git a/lib/dal/src/change_set.rs b/lib/dal/src/change_set.rs index c4386cabd0..37ba186360 100644 --- a/lib/dal/src/change_set.rs +++ b/lib/dal/src/change_set.rs @@ -110,7 +110,7 @@ pub enum ChangeSetError { #[error("tokio join error: {0}")] Join(#[from] tokio::task::JoinError), #[error("layer db error: {0}")] - LayerDb(#[from] LayerDbError), + LayerDb(#[from] Box), #[error("ulid monotonic error: {0}")] Monotonic(#[from] ulid::MonotonicError), #[error("mutex error: {0}")] @@ -124,9 +124,9 @@ pub enum ChangeSetError { #[error("Changeset {0} does not have a workspace snapshot")] NoWorkspaceSnapshot(ChangeSetId), #[error("pg error: {0}")] - Pg(#[from] PgError), + Pg(#[from] Box), #[error("rebaser client error: {0}")] - RebaserClient(#[from] rebaser_client::ClientError), + RebaserClient(#[from] Box), #[error("schema error: {0}")] Schema(#[from] Box), #[error("schema variant error: {0}")] @@ -134,11 +134,11 @@ pub enum ChangeSetError { #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("si db error: {0}")] - SiDb(#[from] si_db::Error), + SiDb(#[from] Box), #[error("slow runtime error: {0}")] SlowRuntime(#[from] SlowRuntimeError), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("ulid decode error: {0}")] UlidDecode(#[from] ulid::DecodeError), #[error( @@ -153,15 +153,75 @@ pub enum ChangeSetError { WsEvent(#[from] Box), } +impl From for ChangeSetError { + fn from(value: LayerDbError) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetError { + fn from(value: si_db::Error) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetError { + fn from(value: PgError) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetError { + fn from(value: rebaser_client::ClientError) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + impl From for ChangeSetError { fn from(value: WorkspaceError) -> Self { - Self::Workspace(Box::new(value)) + Box::new(value).into() } } impl From for ChangeSetError { fn from(value: WsEventError) -> Self { - Self::WsEvent(Box::new(value)) + Box::new(value).into() + } +} + +impl From for ChangeSetApplyError { + fn from(value: ActionError) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetApplyError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetApplyError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetApplyError { + fn from(value: si_db::Error) -> Self { + Box::new(value).into() + } +} + +impl From for ChangeSetApplyError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() } } @@ -173,15 +233,15 @@ pub type ChangeSetResult = Result; #[derive(Debug, Error)] pub enum ChangeSetApplyError { #[error("action error: {0}")] - Action(#[from] ActionError), + Action(#[from] Box), #[error("action prototype not found for id: {0}")] ActionPrototypeNotFound(ActionId), #[error("Cannot apply changeset {0} to itself")] CannotApplyToItself(ChangeSetId), #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("invalid user: {0}")] InvalidUser(UserPk), #[error("invalid user system init")] @@ -189,9 +249,9 @@ pub enum ChangeSetApplyError { #[error("change set ({0}) does not have a base change set")] NoBaseChangeSet(ChangeSetId), #[error("si db error: {0}")] - SiDb(#[from] si_db::Error), + SiDb(#[from] Box), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), } /// A superset of [`ChangeSetResult`] used when performing apply logic. @@ -1084,7 +1144,7 @@ impl ChangeSet { } pub async fn extract_userid_from_context(ctx: &DalContext) -> Option { - let user_id = match ctx.history_actor() { + match ctx.history_actor() { HistoryActor::User(user_pk) => { let maybe_user = User::get_by_pk_opt(ctx, *user_pk).await; match maybe_user { @@ -1093,9 +1153,9 @@ impl ChangeSet { } } HistoryActor::SystemInit => None, - }; - user_id + } } + pub async fn extract_userid_from_context_or_error(ctx: &DalContext) -> ChangeSetResult { let user_id = match ctx.history_actor() { HistoryActor::User(user_pk) => User::get_by_pk(ctx, *user_pk).await?.pk(), diff --git a/lib/dal/src/component.rs b/lib/dal/src/component.rs index b5056c88a6..4a240cf22a 100644 --- a/lib/dal/src/component.rs +++ b/lib/dal/src/component.rs @@ -210,11 +210,11 @@ pub enum ComponentError { #[error("action prototype error: {0}")] ActionPrototype(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error( "attribute value view could not be generated, root value not found; workspace_pk={0}, change_set_id={1}, component_id={2}" )] @@ -224,7 +224,7 @@ pub enum ComponentError { #[error("change set error: {0}")] ChangeSet(#[from] ChangeSetError), #[error("code view error: {0}")] - CodeView(#[from] CodeViewError), + CodeView(#[from] Box), #[error("component {0} already has a geometry for view {1}")] ComponentAlreadyInView(ComponentId, ViewId), #[error("component has children, cannot change to component type")] @@ -256,17 +256,17 @@ pub enum ComponentError { #[error("frame error: {0}")] Frame(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgumentError(#[from] FuncArgumentError), + FuncArgumentError(#[from] Box), #[error("func binding error: {0}")] FuncBinding(#[from] Box), #[error("helper error: {0}")] Helper(#[from] HelperError), #[error("InferredConnectionGraph Error: {0}")] - InferredConnectionGraph(#[from] InferredConnectionGraphError), + InferredConnectionGraph(#[from] Box), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("input socket {0} not found for component id {1}")] InputSocketNotFoundForComponentId(InputSocketId, ComponentId), #[error("input socket {0} has more than one attribute value")] @@ -286,7 +286,7 @@ pub enum ComponentError { #[error("component {0} missing attribute value for root")] MissingRootProp(ComponentId), #[error("module error: {0}")] - Module(#[from] ModuleError), + Module(#[from] Box), #[error("more than one schema variant found for component: {0}")] MoreThanOneSchemaVariantFound(ComponentId), #[error("found multiple parents for component: {0}")] @@ -302,7 +302,7 @@ pub enum ComponentError { #[error("object prop {0} has no ordering node")] ObjectPropHasNoOrderingNode(PropId), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("output socket has not found for attribute value id {0}")] OutputSocketNotFoundForAttributeValueId(AttributeValueId), #[error("output socket {0} not found for component id {1}")] @@ -314,11 +314,11 @@ pub enum ComponentError { #[error(transparent)] ParseInt(#[from] ParseIntError), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("found prop id ({0}) that is not a prop")] PropIdNotAProp(PropId), #[error("qualification error: {0}")] - Qualification(#[from] QualificationError), + Qualification(#[from] Box), #[error("ordering node not found for qualifications map {0} and component {1}")] QualificationNoOrderingNode(AttributeValueId, ComponentId), #[error("qualification summary error: {0}")] @@ -328,7 +328,7 @@ pub enum ComponentError { #[error("root attribute value not found for component: {0}")] RootAttributeValueNotFound(ComponentId), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant not found for component: {0}")] SchemaVariantNotFound(ComponentId), #[error("serde_json error: {0}")] @@ -356,11 +356,11 @@ pub enum ComponentError { )] UnexpectedExplicitAndInferredSources(ComponentId, ComponentId, ComponentInputSocket), #[error("validation error: {0}")] - Validation(#[from] ValidationError), + Validation(#[from] Box), #[error("value source for known prop attribute value {0} is not a prop id")] ValueSourceForPropValueNotPropId(AttributeValueId), #[error("workspace error: {0}")] - Workspace(#[from] WorkspaceError), + Workspace(#[from] Box), #[error("workspace pk not found on context")] WorkspacePkNone, #[error("workspace snapshot error: {0}")] @@ -372,7 +372,7 @@ pub enum ComponentError { #[error("Attribute Prototype Argument used by too many Attribute Prototypes: {0}")] WrongNumberOfPrototypesForAttributePrototypeArgument(AttributePrototypeArgumentId), #[error("WsEvent error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), } impl From for ComponentError { @@ -408,6 +408,102 @@ impl From for ComponentError { } } +impl From for ComponentError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: CodeViewError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: InferredConnectionGraphError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: ModuleError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: QualificationError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: ValidationError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: WorkspaceError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } +} + pub type ComponentResult = Result; pub use si_id::ComponentId; @@ -4085,7 +4181,7 @@ impl Component { if name.ends_with("- Copy") { name } else { - format!("{} - Copy", name) + format!("{name} - Copy") } } diff --git a/lib/dal/src/component/debug.rs b/lib/dal/src/component/debug.rs index 9e5df33b0d..ee34de31f9 100644 --- a/lib/dal/src/component/debug.rs +++ b/lib/dal/src/component/debug.rs @@ -90,25 +90,25 @@ pub struct ComponentDebugData { #[derive(Error, Debug)] pub enum ComponentDebugViewError { #[error("attribute debug view error: {0}")] - AttributeDebugViewError(#[from] AttributeDebugViewError), + AttributeDebugViewError(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("Attribute Value tree badly constructed with root prop of {0}")] AttributeValueTreeBad(AttributeValueId), #[error("component error: {0}")] Component(String), #[error("component error: {0}")] - ComponentError(#[from] ComponentError), + ComponentError(#[from] Box), #[error("diagram error: {0}")] - Diagram(#[from] DiagramError), + Diagram(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("input socket error: {0}")] - InputSocketError(#[from] InputSocketError), + InputSocketError(#[from] Box), #[error("json pointer not found: {1:?} at {0}")] JSONPointerNotFound(serde_json::Value, String), #[error("node weight error: {0}")] - NodeWeightError(#[from] NodeWeightError), + NodeWeightError(#[from] Box), #[error("no internal provider for prop {0}")] NoInternalProvider(PropId), #[error("no root prop found for schema variant {0}")] @@ -118,21 +118,21 @@ pub enum ComponentDebugViewError { #[error("component not found {0}")] NotFound(ComponentId), #[error("output socket error: {0}")] - OutputSocketError(#[from] OutputSocketError), + OutputSocketError(#[from] Box), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("secret error: {0}")] - Secret(#[from] SecretError), + Secret(#[from] Box), #[error("secret not found: {0}")] SecretNotFound(SecretId), #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("socket debug view error: {0}")] - SocketDebugViewError(#[from] SocketDebugViewError), + SocketDebugViewError(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshotError(#[from] WorkspaceSnapshotError), + WorkspaceSnapshotError(#[from] Box), } impl ComponentDebugView { @@ -216,7 +216,7 @@ impl ComponentDebugData { let name = component .name(ctx) .await - .map_err(|e| ComponentDebugViewError::Component(format!("get name error: {}", e)))?; + .map_err(|e| ComponentDebugViewError::Component(format!("get name error: {e}")))?; let debug_view = ComponentDebugData { name, @@ -275,3 +275,81 @@ impl ComponentDebugData { Ok(AttributeValue::tree_for_component(ctx, component_id).await?) } } + +impl From for ComponentDebugViewError { + fn from(value: AttributeDebugViewError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: DiagramError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: SecretError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: SocketDebugViewError) -> Self { + Box::new(value).into() + } +} + +impl From for ComponentDebugViewError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/component/inferred_connection_graph.rs b/lib/dal/src/component/inferred_connection_graph.rs index 1776333079..5198d25555 100644 --- a/lib/dal/src/component/inferred_connection_graph.rs +++ b/lib/dal/src/component/inferred_connection_graph.rs @@ -57,13 +57,13 @@ pub enum InferredConnectionGraphError { #[error("Component error: {0}")] Component(#[from] Box), #[error("InputSocket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("Missing graph node")] MissingGraphNode, #[error("Orphaned Component")] OrphanedComponent(ComponentId), #[error("OutputSocket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("Unable to compute costs for inferred connections")] UnableToComputeCost, #[error("Unsupported Component type {0} for Component {1}")] @@ -780,3 +780,15 @@ fn cost_visitor( } } } + +impl From for InferredConnectionGraphError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for InferredConnectionGraphError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/context.rs b/lib/dal/src/context.rs index 7a048374df..a789bdcec1 100644 --- a/lib/dal/src/context.rs +++ b/lib/dal/src/context.rs @@ -1633,7 +1633,7 @@ impl DalContextBuilder { #[derive(Debug, Error, EnumDiscriminants)] pub enum TransactionsError { #[error("audit logging error: {0}")] - AuditLogging(#[from] AuditLoggingError), + AuditLogging(#[from] Box), #[error("expected a {0:?} activity, but received a {1:?}")] BadActivity(ActivityPayloadDiscriminants, ActivityPayloadDiscriminants), /// Intentionally a bit vague as its used when either the user in question doesn't have access @@ -1646,31 +1646,31 @@ pub enum TransactionsError { #[error("change set not set on DalContext")] ChangeSetNotSet, #[error("job queue processor error: {0}")] - JobQueueProcessor(#[from] JobQueueProcessorError), + JobQueueProcessor(#[from] Box), #[error("tokio join error: {0}")] Join(#[from] tokio::task::JoinError), #[error("layer db error: {0}")] - LayerDb(#[from] LayerDbError), + LayerDb(#[from] Box), #[error("nats error: {0}")] Nats(#[from] NatsError), #[error("no base change set for change set: {0}")] NoBaseChangeSet(ChangeSetId), #[error("pg error: {0}")] - Pg(#[from] PgError), + Pg(#[from] Box), #[error("pg pool error: {0}")] - PgPool(#[from] PgPoolError), + PgPool(#[from] Box), #[error("rebase of batch {0} for change set id {1} failed: {2}")] RebaseFailed(RebaseBatchAddressKind, ChangeSetId, String), #[error("rebaser client error: {0}")] - Rebaser(#[from] rebaser_client::ClientError), + Rebaser(#[from] Box), #[error("rebaser reply deadline elapsed; waited={0:?}, request_id={1}")] RebaserReplyDeadlineElasped(Duration, RequestId), #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("si db error: {0}")] - SiDb(#[from] si_db::Error), + SiDb(#[from] Box), #[error("slow rt error: {0}")] - SlowRuntime(#[from] SlowRuntimeError), + SlowRuntime(#[from] Box), #[error("unable to acquire lock: {0}")] TryLock(#[from] tokio::sync::TryLockError), #[error("cannot commit transactions on invalid connections state")] @@ -1689,6 +1689,54 @@ pub enum TransactionsError { pub type TransactionsResult = Result; +impl From for TransactionsError { + fn from(value: AuditLoggingError) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: JobQueueProcessorError) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: LayerDbError) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: PgError) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: PgPoolError) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: rebaser_client::ClientError) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: si_db::Error) -> Self { + Box::new(value).into() + } +} + +impl From for TransactionsError { + fn from(value: SlowRuntimeError) -> Self { + Box::new(value).into() + } +} + impl From for TransactionsError { fn from(err: WorkspaceError) -> Self { Box::new(err).into() @@ -1704,7 +1752,7 @@ impl From for TransactionsError { impl From for TransactionsError { fn from(err: SiDbTransactionsError) -> Self { match err { - SiDbTransactionsError::Pg(err) => TransactionsError::Pg(err), + SiDbTransactionsError::Pg(err) => TransactionsError::Pg(Box::new(err)), SiDbTransactionsError::TxnStart(state) => TransactionsError::TxnStart(state), } } diff --git a/lib/dal/src/diagram.rs b/lib/dal/src/diagram.rs index 5aafa24237..3e8bf44c79 100644 --- a/lib/dal/src/diagram.rs +++ b/lib/dal/src/diagram.rs @@ -107,21 +107,21 @@ use crate::{ #[derive(Error, Debug)] pub enum DiagramError { #[error("approval requirement error: {0}")] - ApprovalRequirement(#[from] ApprovalRequirementError), + ApprovalRequirement(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute prototype not found")] AttributePrototypeNotFound, #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("attribute value not found")] AttributeValueNotFound, #[error("Change Set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("component not found")] ComponentNotFound, #[error("component status not found for component: {0}")] @@ -147,7 +147,7 @@ pub enum DiagramError { #[error("edge not found")] EdgeNotFound, #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("geometry can't represent: {0}")] GeometryCannotRepresentNodeWeight(NodeWeightDiscriminants), #[error("geometry not found: {0}")] @@ -157,19 +157,19 @@ pub enum DiagramError { #[error("geometry not found for view object {0} on view {1}")] GeometryNotFoundForViewObjectAndView(ViewId, ViewId), #[error("Helper error: {0}")] - Helper(#[from] HelperError), + Helper(#[from] Box), #[error("InferredConnectionGraph error: {0}")] - InferredConnectionGraph(#[from] InferredConnectionGraphError), + InferredConnectionGraph(#[from] Box), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("layerdb error: {0}")] LayerDb(#[from] LayerDbError), #[error("node not found")] NodeNotFound, #[error("node weight error: {0}")] - NodeWeight(#[from] NodeWeightError), + NodeWeight(#[from] Box), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error(transparent)] ParseFloat(#[from] ParseFloatError), #[error(transparent)] @@ -181,7 +181,7 @@ pub enum DiagramError { #[error("schema not found")] SchemaNotFound, #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant not found")] SchemaVariantNotFound, #[error("serde error: {0}")] @@ -191,7 +191,7 @@ pub enum DiagramError { #[error("socket not found")] SocketNotFound, #[error("Transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("could not acquire lock: {0}")] TryLock(#[from] tokio::sync::TryLockError), #[error("view category node not found")] @@ -201,9 +201,105 @@ pub enum DiagramError { #[error("view not found for geometry id: {0}")] ViewNotFoundForGeometry(GeometryId), #[error("Workspace error: {0}")] - Workspace(#[from] WorkspaceError), + Workspace(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), +} + +impl From for DiagramError { + fn from(value: ApprovalRequirementError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: HelperError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: InferredConnectionGraphError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: WorkspaceError) -> Self { + Box::new(value).into() + } +} + +impl From for DiagramError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } } pub type DiagramResult = Result; diff --git a/lib/dal/src/entity_kind.rs b/lib/dal/src/entity_kind.rs index 02aa56b803..2277a6108f 100644 --- a/lib/dal/src/entity_kind.rs +++ b/lib/dal/src/entity_kind.rs @@ -18,11 +18,11 @@ use crate::{ #[derive(Error, Debug)] pub enum EntityKindError { #[error("diagram error: {0}")] - Diagram(#[from] DiagramError), + Diagram(#[from] Box), #[error("node not found for entity id {0}")] NodeNotFound(EntityId), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("workspace snapshot error: {0}")] WorkspaceSnapshot(#[from] WorkspaceSnapshotError), } @@ -104,3 +104,15 @@ impl EntityKind { Ok(name) } } + +impl From for EntityKindError { + fn from(value: DiagramError) -> Self { + Box::new(value).into() + } +} + +impl From for EntityKindError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/func/authoring.rs b/lib/dal/src/func/authoring.rs index 977a6c9ca9..3f5e45153d 100644 --- a/lib/dal/src/func/authoring.rs +++ b/lib/dal/src/func/authoring.rs @@ -122,25 +122,25 @@ pub enum FuncAuthoringError { )] ActionKindAlreadyExists(ActionKind, SchemaVariantId), #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("cannot unlock non-default schema variant: {0}")] CannotUnlockNonDefaultSchemaVariant(SchemaVariantId), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("dependent value root error: {0}")] - DependentValueRoot(#[from] DependentValueRootError), + DependentValueRoot(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("func bindings error: {0}")] - FuncBinding(#[from] FuncBindingError), + FuncBinding(#[from] Box), #[error("func named \"{0}\" already exists in this change set")] FuncNameExists(String), #[error("Function options are incompatible with variant")] @@ -148,7 +148,7 @@ pub enum FuncAuthoringError { #[error("func run value sender is gone without sending a value")] FuncRunGone, #[error("func run error: {0}")] - FuncRunner(#[from] FuncRunnerError), + FuncRunner(#[from] Box), #[error("func runner has failed to send a value and exited")] FuncRunnerSend, #[error("invalid func kind for creation: {0}")] @@ -166,15 +166,15 @@ pub enum FuncAuthoringError { #[error("func ({0}) is not runnable with kind: {1}")] NotRunnable(FuncId, FuncKind), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("tokio task join error: {0}")] TokioTaskJoin(#[from] tokio::task::JoinError), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("unexpected func kind ({0}) creating attribute func")] UnexpectedFuncKindCreatingAttributeFunc(FuncKind), #[error( @@ -184,9 +184,105 @@ pub enum FuncAuthoringError { #[error("variant authoring error: {0}")] VariantAuthoringClient(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for FuncAuthoringError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: DependentValueRootError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: FuncBindingError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: FuncRunnerError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncAuthoringError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } type FuncAuthoringResult = Result; diff --git a/lib/dal/src/func/backend.rs b/lib/dal/src/func/backend.rs index 25abc00cd5..96e9047ebc 100644 --- a/lib/dal/src/func/backend.rs +++ b/lib/dal/src/func/backend.rs @@ -79,11 +79,17 @@ pub enum FuncBackendError { #[error("unable to decode ulid")] Ulid(#[from] ulid::DecodeError), #[error("veritech client error: {0}")] - VeritechClient(#[from] veritech_client::ClientError), + VeritechClient(#[from] Box), } pub type FuncBackendResult = Result; +impl From for FuncBackendError { + fn from(value: veritech_client::ClientError) -> Self { + Box::new(value).into() + } +} + // NOTE(nick,zack): do not add "remain::sorted" for postcard de/ser. We need the order to be // retained. #[derive( diff --git a/lib/dal/src/func/binding.rs b/lib/dal/src/func/binding.rs index 866d3bd03c..b1a49652fb 100644 --- a/lib/dal/src/func/binding.rs +++ b/lib/dal/src/func/binding.rs @@ -14,6 +14,7 @@ use serde::{ Deserialize, Serialize, }; +use si_split_graph::SplitGraphError; use strum::{ Display, EnumDiscriminants, @@ -72,7 +73,10 @@ use crate::{ input::InputSocketError, output::OutputSocketError, }, - workspace_snapshot::dependent_value_root::DependentValueRootError, + workspace_snapshot::{ + dependent_value_root::DependentValueRootError, + graph::WorkspaceSnapshotGraphError, + }, }; pub mod action; @@ -90,17 +94,17 @@ pub enum FuncBindingError { )] ActionKindAlreadyExists(ActionKind, SchemaVariantId), #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("action prototype missing")] ActionPrototypeMissing, #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute prototype missing")] AttributePrototypeMissing, #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("cached modules error: {0}")] CachedModules(#[from] crate::cached_module::CachedModuleError), #[error("cannot compile types for func: {0}")] @@ -108,17 +112,17 @@ pub enum FuncBindingError { #[error("cannot set intrinsic func for component: {0}")] CannotSetIntrinsicForComponent(ComponentId), #[error("component error: {0}")] - ComponentError(#[from] ComponentError), + ComponentError(#[from] Box), #[error("dependent value root error: {0}")] DependentValueRoot(#[from] DependentValueRootError), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("func argument missing for func arg: {0} with name: {1}")] FuncArgumentMissing(FuncArgumentId, String), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("invalid attribute prototype argument source: {0}")] InvalidAttributePrototypeArgumentSource(AttributeFuncArgumentSource), #[error("invalid attribute prototype destination: {0}")] @@ -128,19 +132,19 @@ pub enum FuncBindingError { #[error("malformed input for binding: {0:?}")] MalformedInput(AttributeBindingMalformedInput), #[error("management prototype error: {0}")] - ManagementPrototype(#[from] ManagementPrototypeError), + ManagementPrototype(#[from] Box), #[error("no input location given for attribute prototype id ({0}) and func argument id ({1})")] NoInputLocationGiven(AttributePrototypeId, FuncArgumentId), #[error("no output location given for func: {0}")] NoOutputLocationGiven(FuncId), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("schema error: {0}")] - Schema(#[from] SchemaError), + Schema(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("serde error: {0}")] Serde(#[from] serde_json::Error), #[error("unexpected func binding variant: {0:?} (expected: {1:?})")] @@ -152,7 +156,36 @@ pub enum FuncBindingError { #[error("workspace snapshot error: {0}")] WorkspaceSnapshot(#[from] WorkspaceSnapshotError), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl FuncBindingError { + pub fn is_create_graph_cycle(&self) -> bool { + match self { + Self::SchemaVariant(err) => match err.as_ref() { + SchemaVariantError::AttributePrototypeArgument(err) => matches!( + err.as_ref(), + AttributePrototypeArgumentError::WorkspaceSnapshot( + WorkspaceSnapshotError::WorkspaceSnapshotGraph( + WorkspaceSnapshotGraphError::CreateGraphCycle, + ) | WorkspaceSnapshotError::SplitGraph( + SplitGraphError::WouldCreateGraphCycle + ), + ) + ), + _ => false, + }, + Self::AttributePrototypeArgument(err) => matches!( + err.as_ref(), + AttributePrototypeArgumentError::WorkspaceSnapshot( + WorkspaceSnapshotError::WorkspaceSnapshotGraph( + WorkspaceSnapshotGraphError::CreateGraphCycle, + ) | WorkspaceSnapshotError::SplitGraph(SplitGraphError::WouldCreateGraphCycle), + ) + ), + _ => false, + } + } } type FuncBindingResult = Result; @@ -763,3 +796,87 @@ impl FuncBinding { Ok(auth_bindings) } } + +impl From for FuncBindingError { + fn from(value: ManagementPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncBindingError { + fn from(value: SchemaError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/func/binding/attribute.rs b/lib/dal/src/func/binding/attribute.rs index 5e465c7b6f..a5aa652bcb 100644 --- a/lib/dal/src/func/binding/attribute.rs +++ b/lib/dal/src/func/binding/attribute.rs @@ -58,16 +58,19 @@ pub enum AttributeBindingMalformedInput { /// [`SchemaVariant`](crate::SchemaVariant) provided. EventualParentComponentNotFromSchemaVariant(ComponentId, SchemaVariantId), /// When assembling an input location, all options were provided. We only want one. - InputLocationAllOptionsProvided(PropId, InputSocketId, serde_json::Value), + InputLocationAllOptionsProvided(PropId, InputSocketId, Box), /// When assembling an input location, both an [`InputSocketId`](crate::InputSocket) and a raw, static argument /// value were provided. We only want one option to be provided. - InputLocationBothInputSocketAndStaticArgumentValueProvided(InputSocketId, serde_json::Value), + InputLocationBothInputSocketAndStaticArgumentValueProvided( + InputSocketId, + Box, + ), /// When assembling an input location, both a [`PropId`](crate::Prop) and an [`InputSocketId`](crate::InputSocket) /// were provided. We only want one option to be provided. InputLocationBothPropAndInputSocketProvided(PropId, InputSocketId), /// When assembling an input location, both an [`PropId`](crate::Prop) and a raw, static argument /// value were provided. We only want one option to be provided. - InputLocationBothPropAndStaticArgumentValueProvided(PropId, serde_json::Value), + InputLocationBothPropAndStaticArgumentValueProvided(PropId, Box), /// When assembling an input location, no option was provided. We want one option to be provided. InputLocationNoOptionProvided, /// When assembling an output location, both a [`PropId`](crate::Prop) and an [`OutputSocketId`](crate::OutputSocket) @@ -185,7 +188,7 @@ impl AttributeBinding { AttributeBindingMalformedInput::InputLocationAllOptionsProvided( prop_id, input_socket_id, - static_argument_value, + static_argument_value.into(), ), )) } @@ -197,12 +200,18 @@ impl AttributeBinding { )), (Some(prop_id), None, Some(static_argument_value)) => { Err(FuncBindingError::MalformedInput( - AttributeBindingMalformedInput::InputLocationBothPropAndStaticArgumentValueProvided(prop_id, static_argument_value), + AttributeBindingMalformedInput::InputLocationBothPropAndStaticArgumentValueProvided( + prop_id, + static_argument_value.into(), + ), )) } (None, Some(input_socket_id), Some(static_argument_value)) => { Err(FuncBindingError::MalformedInput( - AttributeBindingMalformedInput::InputLocationBothInputSocketAndStaticArgumentValueProvided(input_socket_id, static_argument_value), + AttributeBindingMalformedInput::InputLocationBothInputSocketAndStaticArgumentValueProvided( + input_socket_id, + static_argument_value.into(), + ), )) } (None, None, None) => Err(FuncBindingError::MalformedInput( @@ -803,7 +812,7 @@ impl AttributeBinding { let output_ts = format!("type Output = {};", output_ts_types.join(" | ")); - Ok(format!("{}\n{}", input_ts_types, output_ts)) + Ok(format!("{input_ts_types}\n{output_ts}")) } /// Take the existing [`AttributeBinding`] and recreate it for the new [`Func`] diff --git a/lib/dal/src/func/runner.rs b/lib/dal/src/func/runner.rs index 7fa99ed934..ea67bdc511 100644 --- a/lib/dal/src/func/runner.rs +++ b/lib/dal/src/func/runner.rs @@ -133,17 +133,17 @@ pub enum FuncRunnerError { #[error("action prototype error: {0}")] ActionPrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("before func missing expected code: {0}")] BeforeFuncMissingCode(FuncId), #[error("before func missing expected handler: {0}")] BeforeFuncMissingHandler(FuncId), #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error( "direct authentication func execution is unsupported (must go through \"before funcs\"), found: {0}" )] @@ -155,9 +155,9 @@ pub enum FuncRunnerError { #[error("empty widget options for secret prop id: {0}")] EmptyWidgetOptionsForSecretProp(PropId), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("function backend error: {0}")] - FuncBackend(#[from] FuncBackendError), + FuncBackend(#[from] Box), #[error("func run builder error: {0}")] FuncRunBuilder(#[from] FuncRunBuilderError), #[error("invalid resolver function type: {0}")] @@ -171,7 +171,7 @@ pub enum FuncRunnerError { #[error("no widget options for secret prop id: {0}")] NoWidgetOptionsForSecretProp(PropId), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("reconciliation funcs are no longer supported (found: {0})")] ReconciliationFuncsNoLongerSupported(FuncId), #[error("function run result failure: kind={kind}, message={message}, backend={backend}")] @@ -181,9 +181,9 @@ pub enum FuncRunnerError { backend: String, }, #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("secret error: {0}")] - Secret(#[from] SecretError), + Secret(#[from] Box), #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("si db error: {0}")] @@ -195,7 +195,7 @@ pub enum FuncRunnerError { #[error("too many attribute values for component ({0}) and prop ({1})")] TooManyAttributeValues(ComponentId, PropId), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error( "unexpected value source ({0:?}) for secret prop ({1}), attribute prototype argument ({2}) and component ({3})" )] @@ -210,7 +210,73 @@ pub enum FuncRunnerError { #[error("veritech value encrypt error: {0}")] VeritechValueEncrypt(#[from] VeritechValueEncryptError), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for FuncRunnerError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: FuncBackendError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: SecretError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for FuncRunnerError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } pub type FuncRunnerResult = Result; diff --git a/lib/dal/src/job/consumer.rs b/lib/dal/src/job/consumer.rs index edebe19f6e..4e2f48ad57 100644 --- a/lib/dal/src/job/consumer.rs +++ b/lib/dal/src/job/consumer.rs @@ -51,37 +51,37 @@ use crate::{ #[allow(clippy::large_enum_variant)] pub enum JobConsumerError { #[error("action error: {0}")] - Action(#[from] ActionError), + Action(#[from] Box), #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("ActionProtoype {0} not found")] ActionPrototypeNotFound(ActionPrototypeId), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("billing publish error: {0}")] BillingPublish(#[from] BillingPublishError), #[error("Error blocking on job: {0}")] - BlockingJob(#[from] BlockingJobError), + BlockingJob(#[from] Box), #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("component {0} is destroyed")] ComponentIsDestroyed(ComponentId), #[error("dependent value update error: {0}")] - DependentValueUpdate(#[from] DependentValueUpdateError), + DependentValueUpdate(#[from] Box), #[error("diagram error: {0}")] - Diagram(#[from] DiagramError), + Diagram(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func runner error: {0}")] - FuncRunner(#[from] FuncRunnerError), + FuncRunner(#[from] Box), #[error("Invalid job arguments. Expected: {0} Actual: {1:?}")] InvalidArguments(String, Vec), #[error("std io error: {0}")] Io(#[from] ::std::io::Error), #[error("management function error: {0}")] - ManagementFunc(#[from] ManagementFuncJobError), + ManagementFunc(#[from] Box), #[error("nats error: {0}")] Nats(#[from] NatsError), #[error("nats is unavailable")] @@ -89,7 +89,7 @@ pub enum JobConsumerError { #[error("pg pool error: {0}")] PgPool(#[from] PgPoolError), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("execution of job {0} failed after {1} retry attempts")] RetriesFailed(JobArgsVCurrent, u32), #[error("serde json error: {0}")] @@ -97,15 +97,15 @@ pub enum JobConsumerError { #[error("tokio task error: {0}")] TokioTask(#[from] JoinError), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("ulid decode error: {0}")] UlidDecode(#[from] ulid::DecodeError), #[error("validation error: {0}")] - Validation(#[from] ValidationError), + Validation(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), } impl From for std::io::Error { @@ -114,6 +114,102 @@ impl From for std::io::Error { } } +impl From for JobConsumerError { + fn from(value: ActionError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: DiagramError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: FuncRunnerError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: BlockingJobError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: DependentValueUpdateError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: ManagementFuncJobError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: ValidationError) -> Self { + Box::new(value).into() + } +} + +impl From for JobConsumerError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } +} + pub type JobConsumerResult = Result; pub enum RetryBackoff { diff --git a/lib/dal/src/job/definition/dependent_values_update.rs b/lib/dal/src/job/definition/dependent_values_update.rs index 022926c00e..c2d10c83e2 100644 --- a/lib/dal/src/job/definition/dependent_values_update.rs +++ b/lib/dal/src/job/definition/dependent_values_update.rs @@ -76,33 +76,111 @@ use crate::{ #[derive(Debug, Error)] pub enum DependentValueUpdateError { #[error("action error: {0}")] - Action(#[from] ActionError), + Action(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("dependent value root error: {0}")] - DependentValueRoot(#[from] DependentValueRootError), + DependentValueRoot(#[from] Box), #[error("dependent values update audit log error: {0}")] - DependentValuesUpdateAuditLog(#[from] DependentValueUpdateAuditLogError), + DependentValuesUpdateAuditLog(#[from] Box), #[error("func error: {0}")] - FuncError(#[from] crate::FuncError), + FuncError(#[from] Box), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("status update error: {0}")] - StatusUpdate(#[from] StatusUpdateError), + StatusUpdate(#[from] Box), #[error(transparent)] TokioTask(#[from] JoinError), #[error(transparent)] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for DependentValueUpdateError { + fn from(value: ActionError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: DependentValueRootError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: DependentValueUpdateAuditLogError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: crate::FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: StatusUpdateError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for DependentValueUpdateError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } pub type DependentValueUpdateResult = Result; @@ -679,17 +757,53 @@ pub mod audit_log { #[derive(Debug, Error)] pub enum DependentValueUpdateAuditLogError { #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("write audit log error: {0}")] - WriteAuditLog(#[source] TransactionsError), + WriteAuditLog(#[source] Box), + } + + impl From for DependentValueUpdateAuditLogError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } + } + + impl From for DependentValueUpdateAuditLogError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } + } + + impl From for DependentValueUpdateAuditLogError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } + } + + impl From for DependentValueUpdateAuditLogError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } + } + + impl From for DependentValueUpdateAuditLogError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } + } + + impl From for DependentValueUpdateAuditLogError { + fn from(value: TransactionsError) -> Self { + Self::WriteAuditLog(Box::new(value)) + } } #[instrument( @@ -742,7 +856,7 @@ pub mod audit_log { input_socket.name().to_owned(), ) .await - .map_err(DependentValueUpdateAuditLogError::WriteAuditLog)?; + .map_err(|e| DependentValueUpdateAuditLogError::WriteAuditLog(Box::new(e)))?; } ValueIsFor::OutputSocket(output_socket_id) => { let output_socket = OutputSocket::get_by_id(ctx, output_socket_id).await?; @@ -767,7 +881,7 @@ pub mod audit_log { output_socket.name().to_owned(), ) .await - .map_err(DependentValueUpdateAuditLogError::WriteAuditLog)?; + .map_err(|e| DependentValueUpdateAuditLogError::WriteAuditLog(Box::new(e)))?; } ValueIsFor::Prop(prop_id) => { let prop = Prop::get_by_id(ctx, prop_id).await?; @@ -792,7 +906,7 @@ pub mod audit_log { prop.name, ) .await - .map_err(DependentValueUpdateAuditLogError::WriteAuditLog)?; + .map_err(|e| DependentValueUpdateAuditLogError::WriteAuditLog(Box::new(e)))?; } } diff --git a/lib/dal/src/job/definition/management_func.rs b/lib/dal/src/job/definition/management_func.rs index 1cc223ddd2..6d5a9fe0d9 100644 --- a/lib/dal/src/job/definition/management_func.rs +++ b/lib/dal/src/job/definition/management_func.rs @@ -57,19 +57,19 @@ use crate::{ #[derive(Debug, Error)] pub enum ManagementFuncJobError { #[error("dependent value root error: {0}")] - DependentValueRoot(#[from] DependentValueRootError), + DependentValueRoot(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("management prototype {0} is not valid for component {1}")] InvalidPrototypeForComponent(ManagementPrototypeId, ComponentId), #[error("management error: {0}")] - Management(#[from] ManagementError), + Management(#[from] Box), #[error("management execution state error: {0}")] ManagementFuncExecutionState(#[from] ManagementFuncExecutionError), #[error("management func js execution failed")] ManagementFuncJsExecutionFailed, #[error("management prototype error: {0}")] - ManagementPrototype(#[from] ManagementPrototypeError), + ManagementPrototype(#[from] Box), #[error( "no pending execution for component {0} and management prototype {1} in change set {2}" )] @@ -79,15 +79,57 @@ pub enum ManagementFuncJobError { #[error(transparent)] TokioTask(#[from] JoinError), #[error(transparent)] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error( "management func {0} for component {1} waited too long for dependent values to be calculated" )] WaitedTooLongForDependentValueRoots(ManagementPrototypeId, ComponentId), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for ManagementFuncJobError { + fn from(value: DependentValueRootError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementFuncJobError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementFuncJobError { + fn from(value: ManagementError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementFuncJobError { + fn from(value: ManagementPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementFuncJobError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementFuncJobError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementFuncJobError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } pub type ManagementFuncJobResult = Result; diff --git a/lib/dal/src/job/processor.rs b/lib/dal/src/job/processor.rs index abdb3633e4..668626d5b1 100644 --- a/lib/dal/src/job/processor.rs +++ b/lib/dal/src/job/processor.rs @@ -25,13 +25,19 @@ pub enum JobQueueProcessorError { #[error("missing required workspace_pk")] MissingWorkspacePk, #[error("pinga client error: {0}")] - PingaClient(#[from] pinga_client::ClientError), + PingaClient(#[from] Box), #[error(transparent)] Serde(#[from] serde_json::Error), #[error(transparent)] Transport(Box), } +impl From for JobQueueProcessorError { + fn from(value: pinga_client::ClientError) -> Self { + Box::new(value).into() + } +} + pub type JobQueueProcessorResult = Result; #[async_trait] diff --git a/lib/dal/src/job/producer.rs b/lib/dal/src/job/producer.rs index 2f171a9696..a8f633e74b 100644 --- a/lib/dal/src/job/producer.rs +++ b/lib/dal/src/job/producer.rs @@ -18,9 +18,15 @@ pub enum BlockingJobError { #[error("no access builder found in job info")] NoAccessBuilder, #[error("pinga client error: {0}")] - PingaClient(#[from] pinga_client::ClientError), + PingaClient(#[from] Box), #[error("serde error: {0}")] Serde(String), #[error("A transactions error occurred: {0}")] Transactions(String), } + +impl From for BlockingJobError { + fn from(value: pinga_client::ClientError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/lib.rs b/lib/dal/src/lib.rs index 44a6f55ab4..654a75d1bf 100644 --- a/lib/dal/src/lib.rs +++ b/lib/dal/src/lib.rs @@ -1,5 +1,6 @@ //! The Data Access Layer (DAL) for System Initiative. +#![recursion_limit = "256"] #![warn( clippy::panic, clippy::panic_in_result_fn, diff --git a/lib/dal/src/management/mod.rs b/lib/dal/src/management/mod.rs index 00ed118ed7..6b1d08bf50 100644 --- a/lib/dal/src/management/mod.rs +++ b/lib/dal/src/management/mod.rs @@ -114,19 +114,19 @@ pub mod prototype; #[derive(Debug, Error)] pub enum ManagementError { #[error("action error: {0}")] - Action(#[from] ActionError), + Action(#[from] Box), #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("attributes error: {0}")] - Attributes(#[from] crate::attribute::attributes::Error), + Attributes(#[from] Box), #[error("cannot create component with 'self' as a placeholder")] CannotCreateComponentWithSelfPlaceholder, #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error( "cannot add an action of kind {0} because component {1} does not have an action of that kind" )] @@ -140,27 +140,27 @@ pub enum ManagementError { #[error("Component with management placeholder {0} could not be found")] ComponentWithPlaceholderNotFound(String), #[error("Diagram Error {0}")] - Diagram(#[from] DiagramError), + Diagram(#[from] Box), #[error("Duplicate component placeholder {0}")] DuplicateComponentPlaceholder(String), #[error("frame error: {0}")] - Frame(#[from] FrameError), + Frame(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("Component {0} does not have an input socket with name {1}")] InputSocketDoesNotExist(ComponentId, String), #[error("No existing or created view could be found named: {0}")] NoSuchView(String), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("Component {0} does not have an output socket with name {1}")] OutputSocketDoesNotExist(ComponentId, String), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("schema error: {0}")] - Schema(#[from] SchemaError), + Schema(#[from] Box), #[error("si db error: {0}")] SiDb(#[from] si_db::Error), #[error("transactions error: {0}")] @@ -170,7 +170,7 @@ pub enum ManagementError { #[error("workspace snapshot error: {0}")] WorkspaceSnapshot(#[from] WorkspaceSnapshotError), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), } pub type ManagementResult = Result; @@ -1989,3 +1989,87 @@ fn process_geometry( geometry.offset_by(origin_x, origin_y) } + +impl From for ManagementError { + fn from(value: ActionError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: crate::attribute::attributes::Error) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: DiagramError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: FrameError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementError { + fn from(value: SchemaError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/management/prototype.rs b/lib/dal/src/management/prototype.rs index 7074f7df8f..98b96fb1b0 100644 --- a/lib/dal/src/management/prototype.rs +++ b/lib/dal/src/management/prototype.rs @@ -87,19 +87,19 @@ use crate::{ #[derive(Debug, Error)] pub enum ManagementPrototypeError { #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] crate::attribute::prototype::AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] AttributePrototypeArgument( - #[from] crate::attribute::prototype::argument::AttributePrototypeArgumentError, + #[from] Box, ), #[error("attribute value error: {0}")] - AttributeValue(#[from] crate::attribute::value::AttributeValueError), + AttributeValue(#[from] Box), #[error("cached module error: {0}")] - CachedModule(#[from] CachedModuleError), + CachedModule(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("diagram error: {0}")] - Diagram(#[from] DiagramError), + Diagram(#[from] Box), #[error("empty value within func run value (FuncId {0} and FuncRunId {1})")] EmptyValueWithinFuncRunValue(FuncId, FuncRunId), #[error("func error: {0}")] @@ -107,19 +107,19 @@ pub enum ManagementPrototypeError { #[error("func execution failure error: {0}")] FuncExecutionFailure(String), #[error("func runner error: {0}")] - FuncRunner(#[from] FuncRunnerError), + FuncRunner(#[from] Box), #[error("func runner recv error")] FuncRunnerRecvError, #[error("helper error: {0}")] - Helper(#[from] HelperError), + Helper(#[from] Box), #[error("input socket error: {0}")] - InputSocket(#[from] crate::socket::input::InputSocketError), + InputSocket(#[from] Box), #[error("invalid prototype for component")] InvalidPrototypeForComponent(ManagementPrototypeId, ComponentId), #[error("layer db error: {0}")] LayerDbError(#[from] si_layer_cache::LayerDbError), #[error("management error: {0}")] - Management(#[from] ManagementError), + Management(#[from] Box), #[error("management func execution state error: {0}")] ManagementExecution(#[from] si_db::ManagementFuncExecutionError), #[error("management prototype {0} has no use edge to a function")] @@ -131,11 +131,11 @@ pub enum ManagementPrototypeError { #[error("management prototype {0} not found")] NotFound(ManagementPrototypeId), #[error("output socket error: {0}")] - OutputSocket(#[from] crate::socket::output::OutputSocketError), + OutputSocket(#[from] Box), #[error("schema error: {0}")] - Schema(#[from] SchemaError), + Schema(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("serde json error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("too few variants: {0}")] @@ -143,11 +143,95 @@ pub enum ManagementPrototypeError { #[error("too many variants: {0}")] TooManyVariants(ManagementPrototypeId), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), #[error("ws event error: {0}")] - WsEvent(#[from] WsEventError), + WsEvent(#[from] Box), +} + +impl From for ManagementPrototypeError { + fn from(value: crate::attribute::value::AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: CachedModuleError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: DiagramError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: FuncRunnerError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: HelperError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: crate::socket::input::InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: ManagementError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: crate::socket::output::OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: SchemaError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} + +impl From for ManagementPrototypeError { + fn from(value: WsEventError) -> Self { + Box::new(value).into() + } } pub type ManagementPrototypeResult = Result; diff --git a/lib/dal/src/pkg.rs b/lib/dal/src/pkg.rs index 677ca018bc..ea7194ce2f 100644 --- a/lib/dal/src/pkg.rs +++ b/lib/dal/src/pkg.rs @@ -81,41 +81,41 @@ pub mod import; #[derive(Debug, Error)] pub enum PkgError { #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error("attribute function for context {0:?} has key {1} but is not setting a prop value")] AttributeFuncForKeyMissingProp(import::AttrFuncContext, String), #[error("attribute function for prop {0} has a key {1} but prop kind is {2} not a map)")] AttributeFuncForKeySetOnWrongKind(PropId, String, PropKind), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attrbute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("AttributePrototypeArgument {0} missing FuncArgument {1}")] AttributePrototypeArgumentMissingFuncArgument(AttributePrototypeArgumentId, FuncArgumentId), #[error("attribute value error: {0}")] - AttributeValueError(#[from] AttributeValueError), + AttributeValueError(#[from] Box), #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), + ChangeSet(#[from] Box), #[error("connection annotation error: {0}")] - ConnectionAnnotation(#[from] ConnectionAnnotationError), + ConnectionAnnotation(#[from] Box), #[error("expected data on an SiPkg node, but none found: {0}")] DataNotFound(String), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("func argument for {0} not found with name {1}")] FuncArgumentNotFoundByName(FuncId, String), #[error("action prototype error: {0}")] - FuncBinding(#[from] FuncBindingError), + FuncBinding(#[from] Box), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("found multiple intrinsic func specs for name: {0}")] IntrinsicFuncSpecsMultipleForName(String), #[error("found no intrinsic func specs for name: {0}")] IntrinsicFuncSpecsNoneForName(String), #[error("management prototype error: {0}")] - ManagementPrototype(#[from] ManagementPrototypeError), + ManagementPrototype(#[from] Box), #[error("Missing Func {1} for AttributePrototype {0}")] MissingAttributePrototypeFunc(AttributePrototypeId, FuncId), #[error("Func {0} missing from exported funcs")] @@ -131,9 +131,9 @@ pub enum PkgError { #[error("Unique id missing for node in workspace backup: {0}")] MissingUniqueIdForNode(String), #[error("module error: {0}")] - Module(#[from] ModuleError), + Module(#[from] Box), #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("output socket {0} missing attribute prototype")] OutputSocketMissingPrototype(OutputSocketId), #[error("Package with that hash already installed: {0}")] @@ -143,7 +143,7 @@ pub enum PkgError { #[error("pkg spec error: {0}")] PkgSpec(#[from] SpecError), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("prop {0} missing attribute prototype")] PropMissingPrototype(PropId), #[error("prop {0} not found")] @@ -151,9 +151,9 @@ pub enum PkgError { #[error("prop spec structure is invalid: {0}")] PropSpecChildrenInvalid(String), #[error("schema error: {0}")] - Schema(#[from] SchemaError), + Schema(#[from] Box), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("json serialization error: {0}")] SerdeJson(#[from] serde_json::Error), #[error("si db error: {0}")] @@ -163,19 +163,133 @@ pub enum PkgError { )] TakingOutputSocketAsInputForPropUnsupported(String, String), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("ulid decode error: {0}")] UlidDecode(#[from] ulid::DecodeError), #[error("url parse error: {0}")] Url(#[from] ParseError), #[error("workspace error: {0}")] - Workspace(#[from] WorkspaceError), + Workspace(#[from] Box), #[error("workspace export not supported")] WorkspaceExportNotSupported(), #[error("workspace pk not found on context")] WorkspacePkNone, #[error("workspace snapshot error: {0}")] - WorkspaceSnaphot(#[from] WorkspaceSnapshotError), + WorkspaceSnaphot(#[from] Box), +} + +impl From for PkgError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: ConnectionAnnotationError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: FuncBindingError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: ManagementPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: ModuleError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: SchemaError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: WorkspaceError) -> Self { + Box::new(value).into() + } +} + +impl From for PkgError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } } pub type PkgResult = Result; diff --git a/lib/dal/src/prop.rs b/lib/dal/src/prop.rs index bb8d27b6d0..b49357e520 100644 --- a/lib/dal/src/prop.rs +++ b/lib/dal/src/prop.rs @@ -95,9 +95,9 @@ pub enum PropError { #[error("array missing child element: {0}")] ArrayMissingChildElement(PropId), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("path cannot include - (next element) because it will never yield a result")] CannotSubscribeToNextElement(PropId, String), #[error("change set error: {0}")] @@ -107,9 +107,9 @@ pub enum PropError { #[error("prop {0} of kind {1} does not have an element prop")] ElementPropNotOnKind(PropId, PropKind), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("helper error: {0}")] Helper(#[from] HelperError), #[error("tokio join error: {0}")] @@ -1220,3 +1220,27 @@ impl Prop { ctx.workspace_snapshot()?.ts_type(prop_id).await } } + +impl From for PropError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for PropError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for PropError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for PropError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/property_editor.rs b/lib/dal/src/property_editor.rs index e44b93ccba..261ca60bca 100644 --- a/lib/dal/src/property_editor.rs +++ b/lib/dal/src/property_editor.rs @@ -42,47 +42,47 @@ pub mod values; #[derive(Error, Debug)] pub enum PropertyEditorError { #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("invalid AttributeReadContext: {0}")] BadAttributeReadContext(String), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("component not found")] ComponentNotFound, #[error("cycle detected: {0}")] CycleDetected(AttributeValueId), #[error("node weight error: {0}")] - NodeWeight(#[from] NodeWeightError), + NodeWeight(#[from] Box), #[error("pg error: {0}")] Pg(#[from] PgError), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("property editor value not found by prop id: {0}")] PropertyEditorValueNotFoundByPropId(PropId), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant not found: {0}")] SchemaVariantNotFound(SchemaVariantId), #[error("secret error: {0}")] - Secret(#[from] SecretError), + Secret(#[from] Box), #[error("secret prop for {0} leads to static value")] SecretPropLeadsToStaticValue(AttributeValueId, AttributeValueId), #[error("error serializing/deserializing json: {0}")] SerdeJson(#[from] serde_json::Error), #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), + Transactions(#[from] Box), #[error("could not acquire lock: {0}")] TryLock(#[from] tokio::sync::TryLockError), #[error("validation error: {0}")] - Validation(#[from] ValidationError), + Validation(#[from] Box), #[error("value source error: {0}")] - ValueSource(#[from] ValueSourceError), + ValueSource(#[from] Box), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), } pub type PropertyEditorResult = Result; @@ -100,3 +100,75 @@ pub struct SelectWidgetOption { pub(crate) label: String, pub(crate) value: String, } + +impl From for PropertyEditorError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: NodeWeightError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: SecretError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: TransactionsError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: ValidationError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: ValueSourceError) -> Self { + Box::new(value).into() + } +} + +impl From for PropertyEditorError { + fn from(value: WorkspaceSnapshotError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/qualification.rs b/lib/dal/src/qualification.rs index c2d2508c5e..602509bce5 100644 --- a/lib/dal/src/qualification.rs +++ b/lib/dal/src/qualification.rs @@ -62,11 +62,17 @@ pub struct QualificationSummary { #[derive(Error, Debug)] pub enum QualificationSummaryError { #[error(transparent)] - Component(#[from] ComponentError), + Component(#[from] Box), #[error(transparent)] Pg(#[from] PgError), } +impl From for QualificationSummaryError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + pub type QualificationSummaryResult = Result; impl QualificationSummary { diff --git a/lib/dal/src/schema/variant.rs b/lib/dal/src/schema/variant.rs index d3dbcdafdf..182c28e470 100644 --- a/lib/dal/src/schema/variant.rs +++ b/lib/dal/src/schema/variant.rs @@ -177,7 +177,7 @@ pub enum SchemaVariantError { #[error("attribute prototype error: {0}")] AttributePrototype(#[from] Box), #[error("attribute argument prototype error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute prototype not found for input socket id: {0}")] AttributePrototypeNotFoundForInputSocket(InputSocketId), #[error("attribute prototype not found for output socket id: {0}")] @@ -201,15 +201,15 @@ pub enum SchemaVariantError { #[error("dependent value root error: {0}")] DependentValueRoot(#[from] DependentValueRootError), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("helper error: {0}")] Helper(#[from] HelperError), #[error("{0} exists, but is not a schema variant id")] IdForWrongType(Ulid), #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("InputSocketNodeWeight error: {0}")] InputSocketNodeWeight(#[from] InputSocketNodeWeightError), #[error("layer db error: {0}")] @@ -243,9 +243,9 @@ pub enum SchemaVariantError { #[error("schema spec has no variants")] NoVariants, #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("found prop id {0} that is not a prop")] PropIdNotAProp(PropId), #[error("cannot find prop at path {1} for SchemaVariant {0}")] @@ -253,7 +253,7 @@ pub enum SchemaVariantError { #[error("schema variant {0} has no root node")] RootNodeMissing(SchemaVariantId), #[error("schema error: {0}")] - Schema(#[from] SchemaError), + Schema(#[from] Box), #[error("schema not found for schema variant: {0}")] SchemaNotFound(SchemaVariantId), #[error("schema variant locked: {0}")] @@ -2517,3 +2517,45 @@ impl SchemaVariant { Ok(schema_variants.into_values().collect()) } } + +impl From for SchemaVariantError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for SchemaVariantError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for SchemaVariantError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for SchemaVariantError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for SchemaVariantError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for SchemaVariantError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for SchemaVariantError { + fn from(value: SchemaError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/schema/variant/authoring.rs b/lib/dal/src/schema/variant/authoring.rs index 7f1d8d43e5..8145c4f8be 100644 --- a/lib/dal/src/schema/variant/authoring.rs +++ b/lib/dal/src/schema/variant/authoring.rs @@ -92,33 +92,33 @@ use crate::{ #[derive(Error, Debug)] pub enum VariantAuthoringError { #[error("action prototype error: {0}")] - ActionPrototype(#[from] ActionPrototypeError), + ActionPrototype(#[from] Box), #[error( "found unexpected return type: expected type 'Asset' to be returned for asset func (FuncId {0}): raw error: {1})" )] AssetTypeNotReturnedForAssetFunc(FuncId, String), #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("there already exists a Schema with the name {0}")] DuplicatedSchemaName(String), #[error("empty value within func run value (FuncId {0} and FuncRunId {1})")] EmptyValueWithinFuncRunValue(FuncId, FuncRunId), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func authoring error: {0}")] - FuncAuthoring(#[from] FuncAuthoringError), + FuncAuthoring(#[from] Box), #[error("func execution failure error: {0}")] FuncExecutionFailure(String), #[error("func run error: {0}")] - FuncRun(#[from] FuncRunnerError), + FuncRun(#[from] Box), #[error("func run value sender has terminated without sending")] FuncRunGone, #[error("input socket error: {0}")] - InputSocket(#[from] InputSocketError), + InputSocket(#[from] Box), #[error("layer db error: {0}")] LayerDb(#[from] LayerDbError), #[error("trying to modify locked variant: {0}")] @@ -126,21 +126,21 @@ pub enum VariantAuthoringError { #[error("no new asset was created")] NoAssetCreated, #[error("output socket error: {0}")] - OutputSocket(#[from] OutputSocketError), + OutputSocket(#[from] Box), #[error("pkg error: {0}")] - Pkg(#[from] PkgError), + Pkg(#[from] Box), #[error("constructed package has no schema node")] PkgMissingSchema, #[error("constructed package has no schema variant node")] PkgMissingSchemaVariant, #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("schema error: {0}")] - Schema(#[from] SchemaError), + Schema(#[from] Box), #[error("schema {0} already has unlocked variant: {1}")] SchemaAlreadyUnlocked(SchemaId, SchemaVariantId), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant asset func not found: {0}")] SchemaVariantAssetNotFound(SchemaVariantId), #[error("schema variant not found: {0}")] @@ -157,6 +157,84 @@ pub enum VariantAuthoringError { Spec(#[from] SpecError), } +impl From for VariantAuthoringError { + fn from(value: ActionPrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: FuncAuthoringError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: FuncRunnerError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: PkgError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: SchemaError) -> Self { + Box::new(value).into() + } +} + +impl From for VariantAuthoringError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + type VariantAuthoringResult = Result; const DEFAULT_ASSET_CODE: &str = r#"function main() { diff --git a/lib/dal/src/secret.rs b/lib/dal/src/secret.rs index 61d8773dc4..8995281776 100644 --- a/lib/dal/src/secret.rs +++ b/lib/dal/src/secret.rs @@ -161,15 +161,15 @@ pub use view::{ #[derive(Error, Debug)] pub enum SecretError { #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgument(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgument(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("change set error: {0}")] ChangeSet(#[from] ChangeSetError), #[error("component error: {0}")] - Component(#[from] ComponentError), + Component(#[from] Box), #[error("error when decrypting encrypted secret")] DecryptionFailed, #[error("dependent value root error: {0}")] @@ -181,9 +181,9 @@ pub enum SecretError { #[error("encrypted secret not found for key: {0}")] EncryptedSecretNotFound(EncryptedSecretKey), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func argument error: {0}")] - FuncArgument(#[from] FuncArgumentError), + FuncArgument(#[from] Box), #[error("func argument not found for func ({0}) and name ({1})")] FuncArgumentNotFound(FuncId, String), #[error("helper error: {0}")] @@ -201,11 +201,11 @@ pub enum SecretError { #[error("pg error: {0}")] Pg(#[from] PgError), #[error("prop error: {0}")] - Prop(#[from] PropError), + Prop(#[from] Box), #[error("not an error! prop id is not for a secret during MV build: {0}")] PropIdNotForSecret(PropId), #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant not secret defining: {0}")] SchemaVariantNotSecretDefining(SchemaVariantId), #[error("secret not found: {0}")] @@ -990,6 +990,54 @@ impl fmt::Debug for DecryptedSecret { } } +impl From for SecretError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: SchemaVariantError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: FuncArgumentError) -> Self { + Box::new(value).into() + } +} + +impl From for SecretError { + fn from(value: PropError) -> Self { + Box::new(value).into() + } +} + #[cfg(test)] mod tests { use sodiumoxide::crypto::box_; diff --git a/lib/dal/src/slow_rt.rs b/lib/dal/src/slow_rt.rs index 940c9594a4..95f3ec2f1a 100644 --- a/lib/dal/src/slow_rt.rs +++ b/lib/dal/src/slow_rt.rs @@ -16,7 +16,13 @@ pub static SLOW_RUNTIME: OnceLock = OnceLock::new(); #[derive(Debug, Error)] pub enum SlowRuntimeError { #[error("io error: {0}")] - Io(#[from] std::io::Error), + Io(#[from] Box), +} + +impl From for SlowRuntimeError { + fn from(value: std::io::Error) -> Self { + Box::new(value).into() + } } pub type SlowRuntimeResult = Result; diff --git a/lib/dal/src/socket/connection_annotation.rs b/lib/dal/src/socket/connection_annotation.rs index 91ac4427a0..66a61dba6e 100644 --- a/lib/dal/src/socket/connection_annotation.rs +++ b/lib/dal/src/socket/connection_annotation.rs @@ -105,7 +105,7 @@ impl Display for ConnectionAnnotation { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let mut out = self.tokens.last().ok_or(fmt::Error)?.clone(); for token in self.tokens.iter().rev().skip(1) { - out = format!("{}<{}>", token, out); + out = format!("{token}<{out}>"); } f.serialize_str(out.as_str()) diff --git a/lib/dal/src/socket/debug.rs b/lib/dal/src/socket/debug.rs index 0524e2c415..8ffc13875b 100644 --- a/lib/dal/src/socket/debug.rs +++ b/lib/dal/src/socket/debug.rs @@ -62,17 +62,17 @@ type SocketDebugViewResult = Result; #[derive(Error, Debug)] pub enum SocketDebugViewError { #[error("attribute prototype debug view error: {0}")] - AttributePrototypeDebugViewError(#[from] AttributePrototypeDebugViewError), + AttributePrototypeDebugViewError(#[from] Box), #[error("attribute prototype error: {0}")] - AttributePrototypeError(#[from] AttributePrototypeError), + AttributePrototypeError(#[from] Box), #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), + AttributeValue(#[from] Box), #[error("component error: {0}")] - ComponentError(#[from] ComponentError), + ComponentError(#[from] Box), #[error("input socket error: {0}")] - InputSocketError(#[from] InputSocketError), + InputSocketError(#[from] Box), #[error("output socket error: {0}")] - OutputSocketError(#[from] OutputSocketError), + OutputSocketError(#[from] Box), } impl SocketDebugView { @@ -173,3 +173,39 @@ impl SocketDebugView { Ok(view) } } + +impl From for SocketDebugViewError { + fn from(value: AttributePrototypeDebugViewError) -> Self { + Box::new(value).into() + } +} + +impl From for SocketDebugViewError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for SocketDebugViewError { + fn from(value: AttributeValueError) -> Self { + Box::new(value).into() + } +} + +impl From for SocketDebugViewError { + fn from(value: ComponentError) -> Self { + Box::new(value).into() + } +} + +impl From for SocketDebugViewError { + fn from(value: InputSocketError) -> Self { + Box::new(value).into() + } +} + +impl From for SocketDebugViewError { + fn from(value: OutputSocketError) -> Self { + Box::new(value).into() + } +} diff --git a/lib/dal/src/socket/input.rs b/lib/dal/src/socket/input.rs index 0b315d00e3..dc21be4364 100644 --- a/lib/dal/src/socket/input.rs +++ b/lib/dal/src/socket/input.rs @@ -64,9 +64,9 @@ use crate::{ #[derive(Error, Debug)] pub enum InputSocketError { #[error("attribute prototype error: {0}")] - AttributePrototype(#[from] AttributePrototypeError), + AttributePrototype(#[from] Box), #[error("attribute prototype argument error: {0}")] - AttributePrototypeArgumentError(#[from] AttributePrototypeArgumentError), + AttributePrototypeArgumentError(#[source] Box), #[error("attribute value error: {0}")] AttributeValue(#[from] Box), #[error("change set error: {0}")] @@ -78,7 +78,7 @@ pub enum InputSocketError { #[error("found too many matches for input and socket: {0}, {1}")] FoundTooManyForInputSocketId(InputSocketId, ComponentId), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("helper error: {0}")] Helper(#[from] HelperError), #[error("layer db error: {0}")] @@ -105,6 +105,24 @@ pub enum InputSocketError { WorkspaceSnapshot(#[from] WorkspaceSnapshotError), } +impl From for InputSocketError { + fn from(value: AttributePrototypeArgumentError) -> Self { + Self::AttributePrototypeArgumentError(Box::new(value)) + } +} + +impl From for InputSocketError { + fn from(value: AttributePrototypeError) -> Self { + Box::new(value).into() + } +} + +impl From for InputSocketError { + fn from(value: FuncError) -> Self { + Box::new(value).into() + } +} + pub type InputSocketResult = Result; pub use si_id::InputSocketId; diff --git a/lib/dal/src/validation.rs b/lib/dal/src/validation.rs index d600bc7431..eef674a24e 100644 --- a/lib/dal/src/validation.rs +++ b/lib/dal/src/validation.rs @@ -72,7 +72,7 @@ pub enum ValidationError { #[error("component error: {0}")] Component(#[from] Box), #[error("func error: {0}")] - Func(#[from] FuncError), + Func(#[from] Box), #[error("func run went away before a value could be sent down the channel")] FuncRunGone, #[error("func runner error: {0}")] @@ -94,7 +94,7 @@ pub enum ValidationError { #[error("schema not found")] SchemaNotFound, #[error("schema variant error: {0}")] - SchemaVariant(#[from] SchemaVariantError), + SchemaVariant(#[from] Box), #[error("schema variant not found")] SchemaVariantNotFound, #[error("error serializing/deserializing json: {0}")] @@ -102,7 +102,7 @@ pub enum ValidationError { #[error("transactions error: {0}")] Transactions(#[from] TransactionsError), #[error("workspace snapshot error: {0}")] - WorkspaceSnapshot(#[from] WorkspaceSnapshotError), + WorkspaceSnapshot(#[from] Box), } impl From for ValidationError { @@ -117,12 +117,30 @@ impl From for ValidationError { } } +impl From for ValidationError { + fn from(e: FuncError) -> Self { + Box::new(e).into() + } +} + impl From for ValidationError { fn from(e: FuncRunnerError) -> Self { Box::new(e).into() } } +impl From for ValidationError { + fn from(e: SchemaVariantError) -> Self { + Box::new(e).into() + } +} + +impl From for ValidationError { + fn from(e: WorkspaceSnapshotError) -> Self { + Box::new(e).into() + } +} + pub type ValidationResult = Result; pub use si_id::ValidationOutputId; diff --git a/lib/dal/src/workspace_snapshot/dependent_value_root.rs b/lib/dal/src/workspace_snapshot/dependent_value_root.rs index 5680c5057a..10d187397c 100644 --- a/lib/dal/src/workspace_snapshot/dependent_value_root.rs +++ b/lib/dal/src/workspace_snapshot/dependent_value_root.rs @@ -25,7 +25,13 @@ pub enum DependentValueRootError { #[error("Workspace snapshot error: {0}")] WorkspaceSnapshot(#[from] Box), #[error("transaction error: {0}")] - Transactions(#[from] crate::TransactionsError), + Transactions(#[from] Box), +} + +impl From for DependentValueRootError { + fn from(value: crate::TransactionsError) -> Self { + Box::new(value).into() + } } pub type DependentValueRootResult = Result; diff --git a/lib/dal/src/workspace_snapshot/graph/tests/detect_updates.rs b/lib/dal/src/workspace_snapshot/graph/tests/detect_updates.rs index 8571faf705..caf0f33915 100644 --- a/lib/dal/src/workspace_snapshot/graph/tests/detect_updates.rs +++ b/lib/dal/src/workspace_snapshot/graph/tests/detect_updates.rs @@ -121,7 +121,7 @@ mod test { ] => { assert_eq!(&EdgeWeightKind::new_use(), edge_weight.kind()); } - other => panic!("Unexpected updates: {:?}", other), + other => panic!("Unexpected updates: {other:?}"), } } @@ -180,7 +180,7 @@ mod test { [Update::NewNode { .. }, Update::NewEdge { edge_weight, .. }] => { assert_eq!(&EdgeWeightKind::new_use(), edge_weight.kind()); } - other => panic!("Unexpected updates: {:?}", other), + other => panic!("Unexpected updates: {other:?}"), } } @@ -481,7 +481,7 @@ mod test { assert_eq!(attribute_prototype_id, destination.id.into(),); assert_eq!(&EdgeWeightKind::Prototype(None), edge_weight.kind()); } - other => panic!("Unexpected updates: {:?}", other), + other => panic!("Unexpected updates: {other:?}"), } } diff --git a/lib/dal/src/workspace_snapshot/graph/validator.rs b/lib/dal/src/workspace_snapshot/graph/validator.rs index da5d1ccba4..a3a5e77562 100644 --- a/lib/dal/src/workspace_snapshot/graph/validator.rs +++ b/lib/dal/src/workspace_snapshot/graph/validator.rs @@ -678,7 +678,7 @@ pub fn av_path_from_root( path.push_front("") } (PropKind::Map, None) => path.push_front(""), - (kind, _) => path.push_front(format!("", kind)), + (kind, _) => path.push_front(format!("")), } index = parent_index; } diff --git a/lib/dal/src/workspace_snapshot/graph/validator/connections.rs b/lib/dal/src/workspace_snapshot/graph/validator/connections.rs index b596cf39de..7f01abc09e 100644 --- a/lib/dal/src/workspace_snapshot/graph/validator/connections.rs +++ b/lib/dal/src/workspace_snapshot/graph/validator/connections.rs @@ -644,7 +644,7 @@ impl std::fmt::Display for WithGraph<'_, &'_ ConnectionMigration> { match migration.explicit_connection_id { Some(explicit_connection_id) => { - write!(f, " (explicit connection APA {})", explicit_connection_id) + write!(f, " (explicit connection APA {explicit_connection_id})") } None => write!(f, " (inferred connection)"), } @@ -725,7 +725,7 @@ impl std::fmt::Display for WithGraph<'_, &'_ ConnectionUnmigrateableBecause> { ) } ConnectionUnmigrateableBecause::InvalidGraph { ref error } => { - write!(f, "Invalid graph: {}", error) + write!(f, "Invalid graph: {error}") } ConnectionUnmigrateableBecause::MultipleConnectionsToSameProp => { write!(f, "Multiple connections to the same prop") diff --git a/lib/dal/tests/integration_test/asset.rs b/lib/dal/tests/integration_test/asset.rs index 75ee64b206..bb8a25b1e5 100644 --- a/lib/dal/tests/integration_test/asset.rs +++ b/lib/dal/tests/integration_test/asset.rs @@ -59,9 +59,9 @@ async fn asset_func_execution_papercuts(ctx: &mut DalContext) { Err(box_err) => match box_err.downcast_ref::() { Some(err) => match err { VariantAuthoringError::AssetTypeNotReturnedForAssetFunc(_, _) => {} - err => panic!("{:?}", err), + err => panic!("{err:?}"), }, - None => panic!("{:?}", box_err), + None => panic!("{box_err:?}"), }, } @@ -79,9 +79,9 @@ async fn asset_func_execution_papercuts(ctx: &mut DalContext) { Err(box_err) => match box_err.downcast_ref::() { Some(err) => match err { VariantAuthoringError::AssetTypeNotReturnedForAssetFunc(_, _) => {} - err => panic!("{:?}", err), + err => panic!("{err:?}"), }, - None => panic!("{:?}", box_err), + None => panic!("{box_err:?}"), }, } diff --git a/lib/dal/tests/integration_test/component.rs b/lib/dal/tests/integration_test/component.rs index 6b78c82bf4..e692c69bab 100644 --- a/lib/dal/tests/integration_test/component.rs +++ b/lib/dal/tests/integration_test/component.rs @@ -298,8 +298,7 @@ async fn through_the_wormholes_simple(ctx: &mut DalContext) -> Result<()> { assert!( update_graph .direct_dependencies_of(naming_and_necessity_value_id) - .iter() - .any(|&id| id == rigid_designator_value_id), + .contains(&rigid_designator_value_id), "update graph declares that `naming_and_necessity` value depends on `rigid_designator` value" ); diff --git a/lib/dal/tests/integration_test/component/debug.rs b/lib/dal/tests/integration_test/component/debug.rs index 709af046b2..cac0191b8f 100644 --- a/lib/dal/tests/integration_test/component/debug.rs +++ b/lib/dal/tests/integration_test/component/debug.rs @@ -86,7 +86,7 @@ async fn get_debug_view(ctx: &mut DalContext) { let attribute_path = AttributeValue::get_path_for_id(ctx, rigid_designator_value_id) .await .expect("can't get the path"); - println!("attribute_path: {:?}", attribute_path); + println!("attribute_path: {attribute_path:?}"); assert_eq!( attribute_path, Some(rigid_prop_path.with_replaced_sep("/").to_string()) diff --git a/lib/dal/tests/integration_test/component/upgrade.rs b/lib/dal/tests/integration_test/component/upgrade.rs index 0f848f66a3..0ed7f67a1a 100644 --- a/lib/dal/tests/integration_test/component/upgrade.rs +++ b/lib/dal/tests/integration_test/component/upgrade.rs @@ -1144,12 +1144,12 @@ async fn connections(ctx: &DalContext, component_id: ComponentId) -> Result panic!("attaching child to parent should fail if parent is not a frame"), Err(FrameError::ParentIsNotAFrame(..)) => {} - Err(other_error) => panic!("unexpected error: {0}", other_error), + Err(other_error) => panic!("unexpected error: {other_error}"), } // Change the parent to become a frame. @@ -242,10 +242,7 @@ async fn convert_component_to_frame_and_attach_no_nesting(ctx: &mut DalContext) match component.schema_name.as_str() { "starfield" => starfield_parent_node_id = Some(component.parent_id), "fallout" => fallout_parent_node_id = Some(component.parent_id), - schema_name => panic!( - "unexpected schema name for diagram component: {0}", - schema_name - ), + schema_name => panic!("unexpected schema name for diagram component: {schema_name}"), } } let starfield_parent_node_id = diff --git a/lib/dal/tests/integration_test/func/authoring/binding.rs b/lib/dal/tests/integration_test/func/authoring/binding.rs index 07fa1ceba5..a78aa7484f 100644 --- a/lib/dal/tests/integration_test/func/authoring/binding.rs +++ b/lib/dal/tests/integration_test/func/authoring/binding.rs @@ -8,14 +8,9 @@ use dal::{ Prop, Schema, SchemaVariant, - SchemaVariantError, Secret, - WorkspaceSnapshotError, action::prototype::ActionKind, - attribute::prototype::argument::{ - AttributePrototypeArgument, - AttributePrototypeArgumentError, - }, + attribute::prototype::argument::AttributePrototypeArgument, func::{ argument::{ FuncArgument, @@ -28,7 +23,6 @@ use dal::{ AttributeFuncDestination, EventualParent, FuncBinding, - FuncBindingError, action::ActionBinding, attribute::AttributeBinding, authentication::AuthBinding, @@ -45,7 +39,6 @@ use dal::{ LeafKind, }, }, - workspace_snapshot::graph::WorkspaceSnapshotGraphError, }; use dal_test::{ WorkspaceSignup, @@ -59,7 +52,6 @@ use dal_test::{ }; use itertools::Itertools; use pretty_assertions_sorted::assert_eq; -use si_split_graph::SplitGraphError; mod action; mod attribute; @@ -736,18 +728,8 @@ async fn code_gen_cannot_create_cycle(ctx: &mut DalContext) { .await; match result { - Err(FuncBindingError::SchemaVariant(SchemaVariantError::AttributePrototypeArgument( - AttributePrototypeArgumentError::WorkspaceSnapshot( - WorkspaceSnapshotError::WorkspaceSnapshotGraph( - WorkspaceSnapshotGraphError::CreateGraphCycle, - ) - | WorkspaceSnapshotError::SplitGraph(SplitGraphError::WouldCreateGraphCycle), - ), - ))) => {} - other => panic!( - "Test should fail if we don't get this error, got: {:?}", - other - ), + Err(err) if err.is_create_graph_cycle() => {} + other => panic!("Test should fail if we don't get this error, got: {other:?}"), } } diff --git a/lib/dal/tests/integration_test/management.rs b/lib/dal/tests/integration_test/management.rs index 7116962b0a..607e73e2cf 100644 --- a/lib/dal/tests/integration_test/management.rs +++ b/lib/dal/tests/integration_test/management.rs @@ -89,7 +89,7 @@ async fn exec_mgmt_func( .await .map_err(|err| { if let ManagementPrototypeError::FuncExecutionFailure(ref err) = err { - println!("Error: {}", err); + println!("Error: {err}"); } err })?; diff --git a/lib/dal/tests/integration_test/pkg/mod.rs b/lib/dal/tests/integration_test/pkg/mod.rs index 023f731dff..76656ffb2e 100644 --- a/lib/dal/tests/integration_test/pkg/mod.rs +++ b/lib/dal/tests/integration_test/pkg/mod.rs @@ -246,7 +246,7 @@ async fn child_prop_names( let mut result = vec![]; for Prop { name, id, .. } in Prop::direct_child_props_ordered(ctx, parent_prop_id).await? { let name = match prefix { - Some(prefix) => format!("{}.{}", prefix, name), + Some(prefix) => format!("{prefix}.{name}"), None => name.to_owned(), }; result.push(name.clone()); @@ -273,7 +273,7 @@ async fn child_av_names( for child_av_id in AttributeValue::get_child_av_ids_in_order(ctx, parent_av_id).await? { let name = AttributeValue::prop(ctx, child_av_id).await?.name; let name = match prefix { - Some(prefix) => format!("{}.{}", prefix, name), + Some(prefix) => format!("{prefix}.{name}"), None => name.to_owned(), }; result.push(name.clone()); @@ -291,7 +291,7 @@ fn spec_prop_child_names(parent_prop: &PropSpec, prefix: Option<&str>) -> Vec format!("{}.{}", prefix, name), + Some(prefix) => format!("{prefix}.{name}"), None => name.to_owned(), }; result.push(name.clone()); diff --git a/lib/dal/tests/integration_test/prop.rs b/lib/dal/tests/integration_test/prop.rs index 04e9f7671d..c747891ac2 100644 --- a/lib/dal/tests/integration_test/prop.rs +++ b/lib/dal/tests/integration_test/prop.rs @@ -59,8 +59,7 @@ async fn verify_prop_used_as_input_flag(ctx: &DalContext) -> Result<()> { assert!( container_prop.can_be_used_as_prototype_arg, - "{:?} should be marked as able to be used as a prototype argument", - container_prop_path + "{container_prop_path:?} should be marked as able to be used as a prototype argument" ); } @@ -73,8 +72,7 @@ async fn verify_prop_used_as_input_flag(ctx: &DalContext) -> Result<()> { assert!( !item_prop.can_be_used_as_prototype_arg, - "{:?} should be marked as NOT able to be used as a prototype argument", - item_prop_path + "{item_prop_path:?} should be marked as NOT able to be used as a prototype argument" ); } diff --git a/lib/dal/tests/integration_test/schema/variant/authoring/create_variant.rs b/lib/dal/tests/integration_test/schema/variant/authoring/create_variant.rs index d7ee5e246c..33511cffdd 100644 --- a/lib/dal/tests/integration_test/schema/variant/authoring/create_variant.rs +++ b/lib/dal/tests/integration_test/schema/variant/authoring/create_variant.rs @@ -58,7 +58,7 @@ async fn create_variant(ctx: &mut DalContext) { .await .expect("unable to get asset authoring func"); - let scaffold_func_name = format!("{}Scaffold_", asset_name); + let scaffold_func_name = format!("{asset_name}Scaffold_"); assert!(func.name.contains(&scaffold_func_name)); assert_eq!(func.kind, FuncKind::SchemaVariantDefinition); assert_eq!( diff --git a/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs b/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs index e38ea815c6..b160f56f35 100644 --- a/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs +++ b/lib/dal/tests/integration_test/schema/variant/authoring/save_variant.rs @@ -64,7 +64,7 @@ async fn save_variant(ctx: &mut DalContext) { .await .expect("unable to get asset authoring func"); - let scaffold_func_name = format!("{}Scaffold_", asset_name); + let scaffold_func_name = format!("{asset_name}Scaffold_"); assert!(func.name.contains(&scaffold_func_name)); assert_eq!(func.kind, FuncKind::SchemaVariantDefinition); assert_eq!( diff --git a/lib/dal/tests/integration_test/split_snapshot.rs b/lib/dal/tests/integration_test/split_snapshot.rs index 62c28f2584..7511a76ac3 100644 --- a/lib/dal/tests/integration_test/split_snapshot.rs +++ b/lib/dal/tests/integration_test/split_snapshot.rs @@ -65,7 +65,7 @@ async fn set_av_for_prop_for_component(ctx: &DalContext, component_id: Component #[ignore] async fn create_split_snapshot_workspace(ctx: &mut DalContext) -> Result<()> { const COMPONENTS_COUNT: usize = 25; - println!("test with {} components", COMPONENTS_COUNT); + println!("test with {COMPONENTS_COUNT} components"); let mut legacy_components = vec![]; let view_id = View::get_id_for_default(ctx).await?; diff --git a/lib/dal/tests/integration_test/view.rs b/lib/dal/tests/integration_test/view.rs index 1cc15d56c5..2d05cd1f36 100644 --- a/lib/dal/tests/integration_test/view.rs +++ b/lib/dal/tests/integration_test/view.rs @@ -243,16 +243,15 @@ async fn remove_view_with_exclusive_components(ctx: &mut DalContext) { assert_eq!(1, alternative_diagram.components.len()); let result = View::remove(ctx, new_view.id()).await; - let Err( - DiagramError::WorkspaceSnapshot(WorkspaceSnapshotError::WorkspaceSnapshotGraph( - WorkspaceSnapshotGraphError::ViewRemovalWouldOrphanItems(orphans), - )) - | DiagramError::WorkspaceSnapshot(WorkspaceSnapshotError::ViewRemovalWouldOrphanItems( - orphans, - )), - ) = result - else { - panic!("View removal did not error appropriately: {:?}", result); + let orphans = match result { + Err(DiagramError::WorkspaceSnapshot(err)) => match *err { + WorkspaceSnapshotError::WorkspaceSnapshotGraph( + WorkspaceSnapshotGraphError::ViewRemovalWouldOrphanItems(orphans), + ) + | WorkspaceSnapshotError::ViewRemovalWouldOrphanItems(orphans) => orphans, + _ => panic!("View removal did not error appropriately: {err:?}"), + }, + _ => panic!("View removal did not error appropriately: {result:?}"), }; assert_eq!(vec![Ulid::from(component.id())], orphans,); } diff --git a/lib/data-warehouse-stream-client/src/lib.rs b/lib/data-warehouse-stream-client/src/lib.rs index 0f6122f97e..5299420ff9 100644 --- a/lib/data-warehouse-stream-client/src/lib.rs +++ b/lib/data-warehouse-stream-client/src/lib.rs @@ -46,9 +46,21 @@ pub enum DataWarehouseStreamClientError { #[error("firehose error: {0}")] Firehose(#[from] aws_sdk_firehose::Error), #[error("firehose build error: {0}")] - FirehoseBuild(#[from] aws_sdk_firehose::error::BuildError), + FirehoseBuild(#[from] Box), #[error("firehose put record error: {0}")] - FirehosePutRecord(#[from] aws_sdk_firehose::error::SdkError), + FirehosePutRecord(#[from] Box>), +} + +impl From for DataWarehouseStreamClientError { + fn from(value: aws_sdk_firehose::error::BuildError) -> Self { + Box::new(value).into() + } +} + +impl From> for DataWarehouseStreamClientError { + fn from(value: aws_sdk_firehose::error::SdkError) -> Self { + Box::new(value).into() + } } type DataWarehouseStreamClientResult = Result; diff --git a/lib/edda-core/src/nats.rs b/lib/edda-core/src/nats.rs index 460e00a883..0b76c5dd8e 100644 --- a/lib/edda-core/src/nats.rs +++ b/lib/edda-core/src/nats.rs @@ -92,10 +92,7 @@ pub mod subject { ) -> Subject { nats_std::subject::prefixed( prefix, - format!( - "{REQUESTS_SUBJECT_PREFIX}.{}.{}", - workspace_id, change_set_id, - ), + format!("{REQUESTS_SUBJECT_PREFIX}.{workspace_id}.{change_set_id}",), ) } @@ -107,10 +104,7 @@ pub mod subject { ) -> Subject { nats_std::subject::prefixed( prefix, - format!( - "{TASKS_SUBJECT_PREFIX}.{}.{}.process", - workspace_id, change_set_id, - ), + format!("{TASKS_SUBJECT_PREFIX}.{workspace_id}.{change_set_id}.process",), ) } diff --git a/lib/edda-server/src/compressed_request.rs b/lib/edda-server/src/compressed_request.rs index b0f7e3f597..f96a7f663b 100644 --- a/lib/edda-server/src/compressed_request.rs +++ b/lib/edda-server/src/compressed_request.rs @@ -545,7 +545,7 @@ mod tests { assert_eq!(input.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -579,7 +579,7 @@ mod tests { assert_eq!(inputs.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -601,7 +601,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -623,7 +623,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -655,7 +655,7 @@ mod tests { assert_eq!(update.to_snapshot_address, to_snapshot_address); assert_eq!(vec![update.change_batch_address], change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -689,7 +689,7 @@ mod tests { assert_eq!(last_to, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -713,7 +713,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -740,7 +740,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -778,7 +778,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -813,7 +813,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -850,7 +850,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -889,7 +889,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -929,7 +929,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -970,7 +970,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1011,7 +1011,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1037,7 +1037,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1062,7 +1062,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1097,7 +1097,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1134,7 +1134,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert!(change_batch_addresses.is_empty()); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1159,7 +1159,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1184,7 +1184,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1217,7 +1217,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(vec![ur.change_batch_address], change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1252,7 +1252,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(vec![ur.change_batch_address], change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1275,7 +1275,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1300,7 +1300,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1324,7 +1324,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1348,7 +1348,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1374,7 +1374,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1399,7 +1399,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1424,7 +1424,7 @@ mod tests { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1462,7 +1462,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } @@ -1500,7 +1500,7 @@ mod tests { assert_eq!(ncsr.to_snapshot_address, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!("wrong variant for compressed request: {:?}", compressed), + _ => panic!("wrong variant for compressed request: {compressed:?}"), } } diff --git a/lib/edda-server/src/compressing_stream.rs b/lib/edda-server/src/compressing_stream.rs index 5ff4a16053..01309cd820 100644 --- a/lib/edda-server/src/compressing_stream.rs +++ b/lib/edda-server/src/compressing_stream.rs @@ -109,7 +109,7 @@ enum State { /// The [`Subject`] to be used on the compressed request ([`Option`] for `mem::take()`) subject: Option, /// The message to be parsed ([`Option`] for `mem::take()`) - message: Option, + message: Box>, /// The stream sequence number of the first message message_stream_sequence: u64, /// A [`Future`] that calculates the read window @@ -365,7 +365,7 @@ where // Set next state and continue loop *this.state = State::CalculateReadWindow { subject, - message: Some(message), + message: Box::new(Some(message)), message_stream_sequence, calculate_read_window_fut: Box::pin(async move { let info: HashMap<_, _> = stream diff --git a/lib/edda-server/tests/integration.rs b/lib/edda-server/tests/integration.rs index 92e4077fc9..560e103acc 100644 --- a/lib/edda-server/tests/integration.rs +++ b/lib/edda-server/tests/integration.rs @@ -79,10 +79,7 @@ async fn multiple_updates() { assert_eq!(last_to, to_snapshot_address); assert_eq!(addresses, change_batch_addresses); } - _ => panic!( - "wrong variant for compressed request: {:?}", - compressed_request - ), + _ => panic!("wrong variant for compressed request: {compressed_request:?}"), } } @@ -147,10 +144,7 @@ async fn updates_with_single_rebuild() { CompressedRequest::Rebuild { src_requests_count } => { assert_eq!(requests.len(), src_requests_count); } - _ => panic!( - "wrong variant for compressed request: {:?}", - compressed_request - ), + _ => panic!("wrong variant for compressed request: {compressed_request:?}"), } } diff --git a/lib/frigg/src/lib.rs b/lib/frigg/src/lib.rs index 9b9c7c5058..f6d83da300 100644 --- a/lib/frigg/src/lib.rs +++ b/lib/frigg/src/lib.rs @@ -645,7 +645,7 @@ mod kv_history { let info = message.info().map_err(|err| { WatcherError::Default( WatcherErrorKind::Other, - format!("failed to parse message metadata: {}", err), + format!("failed to parse message metadata: {err}"), ) })?; if info.pending == 0 { diff --git a/lib/innit-client/src/lib.rs b/lib/innit-client/src/lib.rs index f21e1235a6..6de18448a5 100644 --- a/lib/innit-client/src/lib.rs +++ b/lib/innit-client/src/lib.rs @@ -198,7 +198,7 @@ impl InnitClient { fn join_path(&self, base_segment: &str, path: &str) -> Result { let clean_path = path.trim_start_matches('/'); - let full_path = format!("{}/{}", base_segment, clean_path); + let full_path = format!("{base_segment}/{clean_path}"); Ok(self.base_url.join(&full_path)?) } diff --git a/lib/innit-client/tests/integration_test/mod.rs b/lib/innit-client/tests/integration_test/mod.rs index 86f44a7078..f778364934 100644 --- a/lib/innit-client/tests/integration_test/mod.rs +++ b/lib/innit-client/tests/integration_test/mod.rs @@ -278,7 +278,7 @@ mod integration_tests { // create two parameters in the same path client .create_parameter( - format!("{}/param1", path_prefix), + format!("{path_prefix}/param1"), "path_test_value".to_string(), ) .await @@ -286,7 +286,7 @@ mod integration_tests { client .create_parameter( - format!("{}/param2", path_prefix), + format!("{path_prefix}/param2"), "path_test_value".to_string(), ) .await diff --git a/lib/innit-server/src/routes/create_parameter.rs b/lib/innit-server/src/routes/create_parameter.rs index 410e7c737f..0764172f20 100644 --- a/lib/innit-server/src/routes/create_parameter.rs +++ b/lib/innit-server/src/routes/create_parameter.rs @@ -25,7 +25,7 @@ pub async fn create_parameter_route( Json(CreateParameterRequest { value }): Json, ) -> Result, AppError> { let name = if !name.starts_with('/') { - format!("/{}", name) + format!("/{name}") } else { name.clone() }; diff --git a/lib/innit-server/src/routes/get_parameter.rs b/lib/innit-server/src/routes/get_parameter.rs index 8dfb1b4f86..62b28f14a5 100644 --- a/lib/innit-server/src/routes/get_parameter.rs +++ b/lib/innit-server/src/routes/get_parameter.rs @@ -23,7 +23,7 @@ pub async fn get_parameter_route( }): State, ) -> Result, AppError> { let name = if !name.starts_with('/') { - format!("/{}", name) + format!("/{name}") } else { name.clone() }; diff --git a/lib/innit-server/src/routes/list_parameters.rs b/lib/innit-server/src/routes/list_parameters.rs index 7071debcef..f0cef8df55 100644 --- a/lib/innit-server/src/routes/list_parameters.rs +++ b/lib/innit-server/src/routes/list_parameters.rs @@ -23,7 +23,7 @@ pub async fn list_parameters_route( }): State, ) -> Result, AppError> { let path = if !path.starts_with('/') { - format!("/{}", path) + format!("/{path}") } else { path }; diff --git a/lib/innit-server/src/server.rs b/lib/innit-server/src/server.rs index 59a2fb6c5c..f83dbf4da1 100644 --- a/lib/innit-server/src/server.rs +++ b/lib/innit-server/src/server.rs @@ -199,7 +199,7 @@ pub fn build_service( tracing::error!(error = %err, "Unexpected error in request processing"); Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) - .body(format!("Internal server error: {}", err)) + .body(format!("Internal server error: {err}")) .expect("Unable to build error response body") .into_response() })) diff --git a/lib/luminork-server/src/lib.rs b/lib/luminork-server/src/lib.rs index 12f0dcdec5..8bff1a3276 100644 --- a/lib/luminork-server/src/lib.rs +++ b/lib/luminork-server/src/lib.rs @@ -90,9 +90,15 @@ pub enum ServerError { #[error("Failed to set up signal handler")] Signal(#[source] io::Error), #[error("Permissions error: {0}")] - SpiceDb(#[from] SpiceDbError), + SpiceDb(#[from] Box), #[error("unix domain socket incoming stream error: {0}")] Uds(#[from] uds::UdsIncomingStreamError), } +impl From for ServerError { + fn from(value: SpiceDbError) -> Self { + Box::new(value).into() + } +} + type ServerResult = std::result::Result; diff --git a/lib/luminork-server/src/routes.rs b/lib/luminork-server/src/routes.rs index 3ee1fe346d..4128eee580 100644 --- a/lib/luminork-server/src/routes.rs +++ b/lib/luminork-server/src/routes.rs @@ -155,7 +155,7 @@ pub fn routes(state: AppState) -> Router { let mut spec = serde_json::to_value(original_response.0).map_err(|e| { ( StatusCode::INTERNAL_SERVER_ERROR, - format!("JSON conversion error: {}", e), + format!("JSON conversion error: {e}"), ) })?; diff --git a/lib/luminork-server/src/service/v1/actions/mod.rs b/lib/luminork-server/src/service/v1/actions/mod.rs index e49e04f356..b6bd5b5148 100644 --- a/lib/luminork-server/src/service/v1/actions/mod.rs +++ b/lib/luminork-server/src/service/v1/actions/mod.rs @@ -63,15 +63,15 @@ impl From for ActionsError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - ActionsError::Validation(format!("Invalid JSON data format: {}", rejection)) + ActionsError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - ActionsError::Validation(format!("Invalid JSON syntax: {}", rejection)) + ActionsError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => ActionsError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => ActionsError::Validation(format!("JSON validation error: {}", rejection)), + _ => ActionsError::Validation(format!("JSON validation error: {rejection}")), } } } diff --git a/lib/luminork-server/src/service/v1/change_sets/mod.rs b/lib/luminork-server/src/service/v1/change_sets/mod.rs index 1a45b1e1ee..d49d4ea27f 100644 --- a/lib/luminork-server/src/service/v1/change_sets/mod.rs +++ b/lib/luminork-server/src/service/v1/change_sets/mod.rs @@ -82,15 +82,15 @@ impl From for ChangeSetError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - ChangeSetError::Validation(format!("Invalid JSON data format: {}", rejection)) + ChangeSetError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - ChangeSetError::Validation(format!("Invalid JSON syntax: {}", rejection)) + ChangeSetError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => ChangeSetError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => ChangeSetError::Validation(format!("JSON validation error: {}", rejection)), + _ => ChangeSetError::Validation(format!("JSON validation error: {rejection}")), } } } diff --git a/lib/luminork-server/src/service/v1/components/execute_management_function.rs b/lib/luminork-server/src/service/v1/components/execute_management_function.rs index d859480718..ce0c3a5407 100644 --- a/lib/luminork-server/src/service/v1/components/execute_management_function.rs +++ b/lib/luminork-server/src/service/v1/components/execute_management_function.rs @@ -92,8 +92,7 @@ pub async fn execute_management_function( view.id() } else { return Err(ComponentsError::ViewNotFound(format!( - "View '{}' not found", - view_name + "View '{view_name}' not found" ))); } } else { diff --git a/lib/luminork-server/src/service/v1/components/mod.rs b/lib/luminork-server/src/service/v1/components/mod.rs index 3ed1da4eb2..dd02fab3a4 100644 --- a/lib/luminork-server/src/service/v1/components/mod.rs +++ b/lib/luminork-server/src/service/v1/components/mod.rs @@ -187,8 +187,7 @@ pub async fn resolve_secret_id( .find(|s| s.name() == value_str) .ok_or_else(|| { ComponentsError::SecretNotFound(format!( - "Secret '{}' not found", - value_str + "Secret '{value_str}' not found" )) })?; Ok(found_secret.id()) @@ -199,14 +198,13 @@ pub async fn resolve_secret_id( .into_iter() .find(|s| s.name() == value_str) .ok_or_else(|| { - ComponentsError::SecretNotFound(format!("Secret '{}' not found", value_str)) + ComponentsError::SecretNotFound(format!("Secret '{value_str}' not found")) })?; Ok(found_secret.id()) } } _ => Err(ComponentsError::InvalidSecretValue(format!( - "Secret value must be a string containing ID or name, got: {}", - value + "Secret value must be a string containing ID or name, got: {value}" ))), } } @@ -228,15 +226,15 @@ impl From for ComponentsError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - ComponentsError::Validation(format!("Invalid JSON data format: {}", rejection)) + ComponentsError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - ComponentsError::Validation(format!("Invalid JSON syntax: {}", rejection)) + ComponentsError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => ComponentsError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => ComponentsError::Validation(format!("JSON validation error: {}", rejection)), + _ => ComponentsError::Validation(format!("JSON validation error: {rejection}")), } } } diff --git a/lib/luminork-server/src/service/v1/funcs/mod.rs b/lib/luminork-server/src/service/v1/funcs/mod.rs index 06b1606903..9f40c629bf 100644 --- a/lib/luminork-server/src/service/v1/funcs/mod.rs +++ b/lib/luminork-server/src/service/v1/funcs/mod.rs @@ -57,15 +57,15 @@ impl From for FuncsError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - FuncsError::Validation(format!("Invalid JSON data format: {}", rejection)) + FuncsError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - FuncsError::Validation(format!("Invalid JSON syntax: {}", rejection)) + FuncsError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => FuncsError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => FuncsError::Validation(format!("JSON validation error: {}", rejection)), + _ => FuncsError::Validation(format!("JSON validation error: {rejection}")), } } } diff --git a/lib/luminork-server/src/service/v1/management_funcs/mod.rs b/lib/luminork-server/src/service/v1/management_funcs/mod.rs index 77261d54a9..a032ab3fcc 100644 --- a/lib/luminork-server/src/service/v1/management_funcs/mod.rs +++ b/lib/luminork-server/src/service/v1/management_funcs/mod.rs @@ -42,15 +42,15 @@ impl From for ManagementFuncsError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - ManagementFuncsError::Validation(format!("Invalid JSON data format: {}", rejection)) + ManagementFuncsError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - ManagementFuncsError::Validation(format!("Invalid JSON syntax: {}", rejection)) + ManagementFuncsError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => ManagementFuncsError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => ManagementFuncsError::Validation(format!("JSON validation error: {}", rejection)), + _ => ManagementFuncsError::Validation(format!("JSON validation error: {rejection}")), } } } diff --git a/lib/luminork-server/src/service/v1/schemas/mod.rs b/lib/luminork-server/src/service/v1/schemas/mod.rs index 4fdf88cbf9..80fcfbb8e8 100644 --- a/lib/luminork-server/src/service/v1/schemas/mod.rs +++ b/lib/luminork-server/src/service/v1/schemas/mod.rs @@ -102,15 +102,15 @@ impl From for SchemaError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - SchemaError::Validation(format!("Invalid JSON data format: {}", rejection)) + SchemaError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - SchemaError::Validation(format!("Invalid JSON syntax: {}", rejection)) + SchemaError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => SchemaError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => SchemaError::Validation(format!("JSON validation error: {}", rejection)), + _ => SchemaError::Validation(format!("JSON validation error: {rejection}")), } } } @@ -495,7 +495,7 @@ fn build_prop_schema_from_maps( ) -> SchemaResult { let prop = props_map .get(&prop_id) - .ok_or_else(|| SchemaError::Validation(format!("Prop {} not found in map", prop_id)))?; + .ok_or_else(|| SchemaError::Validation(format!("Prop {prop_id} not found in map")))?; let prop_type = match prop.kind { PropKind::String => "string", diff --git a/lib/luminork-server/src/service/v1/secrets/mod.rs b/lib/luminork-server/src/service/v1/secrets/mod.rs index 8814cc6309..a0344262f5 100644 --- a/lib/luminork-server/src/service/v1/secrets/mod.rs +++ b/lib/luminork-server/src/service/v1/secrets/mod.rs @@ -72,15 +72,15 @@ impl From for SecretsError { fn from(rejection: JsonRejection) -> Self { match rejection { JsonRejection::JsonDataError(_) => { - SecretsError::Validation(format!("Invalid JSON data format: {}", rejection)) + SecretsError::Validation(format!("Invalid JSON data format: {rejection}")) } JsonRejection::JsonSyntaxError(_) => { - SecretsError::Validation(format!("Invalid JSON syntax: {}", rejection)) + SecretsError::Validation(format!("Invalid JSON syntax: {rejection}")) } JsonRejection::MissingJsonContentType(_) => SecretsError::Validation( "Request must have Content-Type: application/json header".to_string(), ), - _ => SecretsError::Validation(format!("JSON validation error: {}", rejection)), + _ => SecretsError::Validation(format!("JSON validation error: {rejection}")), } } } diff --git a/lib/module-index-client/src/lib.rs b/lib/module-index-client/src/lib.rs index 5a28c0265b..28784f7723 100644 --- a/lib/module-index-client/src/lib.rs +++ b/lib/module-index-client/src/lib.rs @@ -293,7 +293,7 @@ impl ModuleIndexClient { let details_url = self .base_url .join("modules/")? - .join(&format!("{}", module_id))?; + .join(&format!("{module_id}"))?; let response = self.inner.get(details_url).send().await?; diff --git a/lib/module-index-server/src/extract.rs b/lib/module-index-server/src/extract.rs index 7085304300..d19bb44331 100644 --- a/lib/module-index-server/src/extract.rs +++ b/lib/module-index-server/src/extract.rs @@ -44,7 +44,7 @@ impl ExtractedS3Bucket { async fn get_url(self, object_key: String) -> Result { let download_url = if let Some(domain) = self.cloudfront_domain { - format!("https://{}/{}", domain, object_key) + format!("https://{domain}/{object_key}") } else { self.s3_bucket.presign_get(object_key, 60 * 5, None).await? }; diff --git a/lib/module-index-server/src/routes/upsert_workspace_route.rs b/lib/module-index-server/src/routes/upsert_workspace_route.rs index 7f1340ea41..f0e4ebd0c2 100644 --- a/lib/module-index-server/src/routes/upsert_workspace_route.rs +++ b/lib/module-index-server/src/routes/upsert_workspace_route.rs @@ -128,7 +128,7 @@ pub async fn upsert_workspace_route( }; s3_bucket - .put_object(format!("{}.workspace_export", hash), &data) + .put_object(format!("{hash}.workspace_export"), &data) .await?; let _new_module: si_module::Model = dbg!(new_module.insert(&txn).await)?; diff --git a/lib/module-index-server/src/server.rs b/lib/module-index-server/src/server.rs index 44f88636df..34e16323f4 100644 --- a/lib/module-index-server/src/server.rs +++ b/lib/module-index-server/src/server.rs @@ -341,7 +341,7 @@ pub fn build_service( tracing::error!(error = %err, "Unexpected error in request processing"); Response::builder() .status(StatusCode::INTERNAL_SERVER_ERROR) - .body(format!("Internal server error: {}", err)) + .body(format!("Internal server error: {err}")) .expect("Unable to build error response body") .into_response() })) diff --git a/lib/nats-multiplexer/src/lib.rs b/lib/nats-multiplexer/src/lib.rs index ebdd771f70..79bec9c5a8 100644 --- a/lib/nats-multiplexer/src/lib.rs +++ b/lib/nats-multiplexer/src/lib.rs @@ -63,8 +63,6 @@ mod parsing; #[remain::sorted] #[derive(Debug, Error)] pub enum MultiplexerError { - #[error("broadcast send nats message error: {0}")] - BroadcastSentNatsMessage(#[from] broadcast::error::SendError), #[error("nats error: {0}")] Nats(#[from] si_data_nats::Error), } diff --git a/lib/object-tree/src/graph.rs b/lib/object-tree/src/graph.rs index 348cc4ec79..6dd15ad8ce 100644 --- a/lib/object-tree/src/graph.rs +++ b/lib/object-tree/src/graph.rs @@ -882,8 +882,7 @@ fn read_node_entry_lines(reader: &mut R) -> Result, G if !parts.is_empty() { return Err(GraphError::parse_custom(format!( - "entry line has more than 3 fields: {}", - line + "entry line has more than 3 fields: {line}" ))); } diff --git a/lib/permissions/src/lib.rs b/lib/permissions/src/lib.rs index bc1a3a1d19..5649c14cee 100644 --- a/lib/permissions/src/lib.rs +++ b/lib/permissions/src/lib.rs @@ -25,7 +25,13 @@ pub enum Error { )] RelationBuilder { required_fields: Vec }, #[error("spicedb client error: {0}")] - SpiceDb(#[from] SpiceDbError), + SpiceDb(#[from] Box), +} + +impl From for Error { + fn from(value: SpiceDbError) -> Self { + Box::new(value).into() + } } type Result = result::Result; @@ -116,7 +122,7 @@ impl RelationBuilder { Ok(relationship) => client .create_relationships(vec![relationship]) .await - .map_err(Error::SpiceDb), + .map_err(Into::into), Err(err) => Err(err), } } @@ -127,7 +133,7 @@ impl RelationBuilder { Ok(relationship) => client .delete_relationships(vec![relationship]) .await - .map_err(Error::SpiceDb), + .map_err(Into::into), Err(err) => Err(err), } } @@ -143,7 +149,7 @@ impl RelationBuilder { self.zed_token.clone(), )) .await - .map_err(Error::SpiceDb), + .map_err(Into::into), _ => Err(Error::RelationBuilder { required_fields: vec!["object".to_string(), "relation".to_string()], }), @@ -237,10 +243,7 @@ impl PermissionBuilder { /// Checks if the given subject has the given permission in the given object pub async fn has_permission(&self, client: &mut SpiceDbClient) -> Result { match self.check_has_permission() { - Ok(perms) => Ok(client - .check_permissions(perms) - .await - .map_err(Error::SpiceDb)?), + Ok(perms) => client.check_permissions(perms).await.map_err(Into::into), Err(err) => Err(err), } } diff --git a/lib/pinga-core/src/nats.rs b/lib/pinga-core/src/nats.rs index 72b01e7099..84417a9182 100644 --- a/lib/pinga-core/src/nats.rs +++ b/lib/pinga-core/src/nats.rs @@ -52,10 +52,7 @@ pub mod subject { ) -> Subject { nats_std::subject::prefixed( prefix, - format!( - "{SUBJECT_PREFIX}.{}.{}.{}", - workspace_id, change_set_id, args, - ), + format!("{SUBJECT_PREFIX}.{workspace_id}.{change_set_id}.{args}",), ) } } diff --git a/lib/rebaser-core/src/nats.rs b/lib/rebaser-core/src/nats.rs index 2a4928e228..7fa967c2aa 100644 --- a/lib/rebaser-core/src/nats.rs +++ b/lib/rebaser-core/src/nats.rs @@ -89,10 +89,7 @@ pub mod subject { ) -> Subject { nats_std::subject::prefixed( prefix, - format!( - "{REQUESTS_SUBJECT_PREFIX}.{}.{}", - workspace_id, change_set_id, - ), + format!("{REQUESTS_SUBJECT_PREFIX}.{workspace_id}.{change_set_id}",), ) } @@ -104,10 +101,7 @@ pub mod subject { ) -> Subject { nats_std::subject::prefixed( prefix, - format!( - "{TASKS_SUBJECT_PREFIX}.{}.{}.process", - workspace_id, change_set_id, - ), + format!("{TASKS_SUBJECT_PREFIX}.{workspace_id}.{change_set_id}.process",), ) } } diff --git a/lib/sdf-server/src/lib.rs b/lib/sdf-server/src/lib.rs index 4bb1398943..153621f57d 100644 --- a/lib/sdf-server/src/lib.rs +++ b/lib/sdf-server/src/lib.rs @@ -100,9 +100,15 @@ pub enum ServerError { #[error("Failed to set up signal handler")] Signal(#[source] io::Error), #[error("Permissions error: {0}")] - SpiceDb(#[from] SpiceDbError), + SpiceDb(#[from] Box), #[error("unix domain socket incoming stream error: {0}")] Uds(#[from] uds::UdsIncomingStreamError), } +impl From for ServerError { + fn from(value: SpiceDbError) -> Self { + Box::new(value).into() + } +} + type ServerResult = std::result::Result; diff --git a/lib/sdf-server/src/service/v2/audit_log.rs b/lib/sdf-server/src/service/v2/audit_log.rs index 91d8586d69..269e2d2a28 100644 --- a/lib/sdf-server/src/service/v2/audit_log.rs +++ b/lib/sdf-server/src/service/v2/audit_log.rs @@ -17,15 +17,33 @@ mod list_audit_logs; #[derive(Debug, Error)] pub enum AuditLogError { #[error("dal audit logging error: {0}")] - DalAuditLogging(#[from] dal::audit_logging::AuditLoggingError), + DalAuditLogging(#[from] Box), #[error("dal change set error: {0}")] - DalChangeSet(#[from] dal::ChangeSetError), + DalChangeSet(#[from] Box), #[error("dal transactions error: {0}")] - DalTransactions(#[from] dal::TransactionsError), + DalTransactions(#[from] Box), #[error("si db error: {0}")] SiDb(#[from] si_db::Error), } +impl From for AuditLogError { + fn from(value: dal::audit_logging::AuditLoggingError) -> Self { + Box::new(value).into() + } +} + +impl From for AuditLogError { + fn from(value: dal::ChangeSetError) -> Self { + Box::new(value).into() + } +} + +impl From for AuditLogError { + fn from(value: dal::TransactionsError) -> Self { + Box::new(value).into() + } +} + pub type AuditLogResult = Result; impl IntoResponse for AuditLogError { diff --git a/lib/sdf-server/src/service/v2/change_set/apply.rs b/lib/sdf-server/src/service/v2/change_set/apply.rs index b98bf69cb5..ad69bf5df0 100644 --- a/lib/sdf-server/src/service/v2/change_set/apply.rs +++ b/lib/sdf-server/src/service/v2/change_set/apply.rs @@ -71,7 +71,7 @@ pub async fn apply( .await?; let actor = ctx.history_actor().email(&ctx).await?; - let change_set_url = format!("https://{}/w/{}/{}", host_name, workspace_pk, change_set_id); + let change_set_url = format!("https://{host_name}/w/{workspace_pk}/{change_set_id}"); let message = format!( "{} applied change set {} to HEAD: {}", actor, change_set_view.name, change_set_url diff --git a/lib/sdf-server/src/service/v2/change_set/approve.rs b/lib/sdf-server/src/service/v2/change_set/approve.rs index 89e89e19d7..ee06460cd4 100644 --- a/lib/sdf-server/src/service/v2/change_set/approve.rs +++ b/lib/sdf-server/src/service/v2/change_set/approve.rs @@ -139,7 +139,7 @@ pub async fn approve( .into_frontend_type(&ctx) .await?; let actor = ctx.history_actor().email(&ctx).await?; - let change_set_url = format!("https://{}/w/{}/{}", host_name, workspace_pk, change_set_id); + let change_set_url = format!("https://{host_name}/w/{workspace_pk}/{change_set_id}"); let message = format!( "{} {} merge of change set {}: {}", actor, diff --git a/lib/sdf-server/src/service/v2/change_set/cancel_approval_request.rs b/lib/sdf-server/src/service/v2/change_set/cancel_approval_request.rs index 379220963a..4c686c90db 100644 --- a/lib/sdf-server/src/service/v2/change_set/cancel_approval_request.rs +++ b/lib/sdf-server/src/service/v2/change_set/cancel_approval_request.rs @@ -68,7 +68,7 @@ pub async fn cancel_approval_request( .publish_on_commit(&ctx) .await?; let actor = ctx.history_actor().email(&ctx).await?; - let change_set_url = format!("https://{}/w/{}/{}", host_name, workspace_pk, change_set_id); + let change_set_url = format!("https://{host_name}/w/{workspace_pk}/{change_set_id}"); let message = format!( "{} withdrew approval request of change set {}: {}", actor, diff --git a/lib/sdf-server/src/service/v2/change_set/request_approval.rs b/lib/sdf-server/src/service/v2/change_set/request_approval.rs index d1e572ce74..5bbd8e655c 100644 --- a/lib/sdf-server/src/service/v2/change_set/request_approval.rs +++ b/lib/sdf-server/src/service/v2/change_set/request_approval.rs @@ -57,7 +57,7 @@ pub async fn request_approval( .await?; let actor = ctx.history_actor().email(&ctx).await?; - let change_set_url = format!("https://{}/w/{}/{}", host_name, workspace_pk, change_set_id); + let change_set_url = format!("https://{host_name}/w/{workspace_pk}/{change_set_id}"); let message = format!( "{} requested an approval of change set {}: {}", actor, diff --git a/lib/sdf-server/src/service/v2/fs.rs b/lib/sdf-server/src/service/v2/fs.rs index ed359a6983..150412ec6c 100644 --- a/lib/sdf-server/src/service/v2/fs.rs +++ b/lib/sdf-server/src/service/v2/fs.rs @@ -146,7 +146,7 @@ pub enum FsError { #[error("func already unlocked: {0}")] FuncAlreadyUnlocked(FuncId), #[error("func api error: {0}")] - FuncApi(#[from] FuncAPIError), + FuncApi(#[from] Box), #[error("func argument error: {0}")] FuncArgument(#[from] FuncArgumentError), #[error("func argument not found with name: {0}")] @@ -197,6 +197,12 @@ pub enum FsError { WsEvent(#[from] WsEventError), } +impl From for FsError { + fn from(value: FuncAPIError) -> Self { + Box::new(value).into() + } +} + pub type FsResult = Result; const ASSET_EDITOR_TYPES: &str = include_str!("./fs/editor_typescript.txt"); diff --git a/lib/sdf-server/src/service/v2/func.rs b/lib/sdf-server/src/service/v2/func.rs index 42c420b365..44d68f4d37 100644 --- a/lib/sdf-server/src/service/v2/func.rs +++ b/lib/sdf-server/src/service/v2/func.rs @@ -19,20 +19,14 @@ use dal::{ Func, FuncError, FuncId, - SchemaVariantError, - WorkspaceSnapshotError, WsEventError, - attribute::{ - prototype::argument::AttributePrototypeArgumentError, - value::AttributeValueError, - }, + attribute::value::AttributeValueError, func::{ argument::FuncArgumentError, authoring::FuncAuthoringError, binding::FuncBindingError, runner::FuncRunnerError, }, - workspace_snapshot::graph::WorkspaceSnapshotGraphError, }; use sdf_core::api_error::ApiError; use si_frontend_types::FuncCode; @@ -181,31 +175,29 @@ impl IntoResponse for FuncAPIError { // Return 404 when the func is not found Self::FuncNotFound(_) | // When a graph node cannot be found for a schema variant, it is not found - Self::SchemaVariant(dal::SchemaVariantError::NotFound(_)) => (StatusCode::NOT_FOUND, None), + Self::SchemaVariant(dal::SchemaVariantError::NotFound(_)) => { + (StatusCode::NOT_FOUND, None) + }, // When the authoring changes requested would result in a cycle - Self::FuncBinding(FuncBindingError::SchemaVariant( - SchemaVariantError::AttributePrototypeArgument( - AttributePrototypeArgumentError::WorkspaceSnapshot( - WorkspaceSnapshotError::WorkspaceSnapshotGraph( - WorkspaceSnapshotGraphError::CreateGraphCycle, - ), - ), - ), - )) - | Self::FuncBinding(FuncBindingError::AttributePrototypeArgument( - AttributePrototypeArgumentError::WorkspaceSnapshot( - WorkspaceSnapshotError::WorkspaceSnapshotGraph( - WorkspaceSnapshotGraphError::CreateGraphCycle, - ), - ), - )) => (StatusCode::UNPROCESSABLE_ENTITY, None), + Self::FuncBinding(func_binding_error) if func_binding_error.is_create_graph_cycle() => { + (StatusCode::UNPROCESSABLE_ENTITY, None) + }, // Return 422 if the error is related to the user code being invalid - Self::FuncAuthoring(FuncAuthoringError::AttributeValue(AttributeValueError::FuncRunner(err))) => - func_runner_err_to_status_and_message(*err), - Self::FuncAuthoring(FuncAuthoringError::FuncRunner(err)) => func_runner_err_to_status_and_message(err), - + Self::FuncAuthoring(FuncAuthoringError::AttributeValue(err)) => { + match *err { + AttributeValueError::FuncRunner(err) => { + func_runner_err_to_status_and_message(*err) + }, + _ => { + (ApiError::DEFAULT_ERROR_STATUS_CODE, None) + }, + } + } + Self::FuncAuthoring(FuncAuthoringError::FuncRunner(err)) => { + func_runner_err_to_status_and_message(*err) + }, _ => (ApiError::DEFAULT_ERROR_STATUS_CODE, None) }; diff --git a/lib/sdf-server/src/service/v2/management/generate_template.rs b/lib/sdf-server/src/service/v2/management/generate_template.rs index 43dc6c7f31..e772c5271d 100644 --- a/lib/sdf-server/src/service/v2/management/generate_template.rs +++ b/lib/sdf-server/src/service/v2/management/generate_template.rs @@ -168,9 +168,7 @@ pub async fn generate_template( r#" const {variable_name}: Output["ops"]["create"][string] = {spec_body}; specs.push({variable_name}); -"#, - variable_name = variable_name, - spec_body = spec_body +"# ); component_sync_code.push_str(&component_code); } diff --git a/lib/sdf-server/src/service/v2/view.rs b/lib/sdf-server/src/service/v2/view.rs index b3fde2edc8..9292e9c3b4 100644 --- a/lib/sdf-server/src/service/v2/view.rs +++ b/lib/sdf-server/src/service/v2/view.rs @@ -127,11 +127,14 @@ impl IntoResponse for ViewError { ViewError::DalDiagram(dal::diagram::DiagramError::ViewNotFound(_)) => { (StatusCode::NOT_FOUND, self.to_string()) } - ViewError::DalDiagram(dal::diagram::DiagramError::WorkspaceSnapshot( - WorkspaceSnapshotError::WorkspaceSnapshotGraph( - WorkspaceSnapshotGraphError::ViewRemovalWouldOrphanItems(_), - ), - )) => (StatusCode::CONFLICT, self.to_string()), + ViewError::DalDiagram(dal::diagram::DiagramError::WorkspaceSnapshot(ref err)) => { + match err.as_ref() { + WorkspaceSnapshotError::WorkspaceSnapshotGraph( + WorkspaceSnapshotGraphError::ViewRemovalWouldOrphanItems(_), + ) => (StatusCode::CONFLICT, self.to_string()), + _ => (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()), + } + } _ => (StatusCode::INTERNAL_SERVER_ERROR, self.to_string()), }; diff --git a/lib/sdf-v1-routes-diagram/src/delete_connection.rs b/lib/sdf-v1-routes-diagram/src/delete_connection.rs index 4c5ea43dc6..d81b934715 100644 --- a/lib/sdf-v1-routes-diagram/src/delete_connection.rs +++ b/lib/sdf-v1-routes-diagram/src/delete_connection.rs @@ -175,7 +175,7 @@ pub async fn delete_connection( to_socket_id: request.to_socket_id, to_socket_name: to_socket_name.clone(), }, - format!("{0}-{1}", to_component_name, to_socket_name), + format!("{to_component_name}-{to_socket_name}"), ) .await?; track( diff --git a/lib/sdf-v1-routes-module/src/lib.rs b/lib/sdf-v1-routes-module/src/lib.rs index 0261da7d08..78ca8d9656 100644 --- a/lib/sdf-v1-routes-module/src/lib.rs +++ b/lib/sdf-v1-routes-module/src/lib.rs @@ -200,8 +200,8 @@ pub async fn pkg_lookup( fn add_pkg_extension(to: &str, version: &str, attempts: usize) -> String { match attempts { - 0 => format!("{}-{}.{}", to, version, PKG_EXTENSION), - more_than_zero => format!("{}-{}-{}.{}", to, version, more_than_zero, PKG_EXTENSION), + 0 => format!("{to}-{version}.{PKG_EXTENSION}"), + more_than_zero => format!("{to}-{version}-{more_than_zero}.{PKG_EXTENSION}"), } } diff --git a/lib/shuttle-server/tests/integration.rs b/lib/shuttle-server/tests/integration.rs index a6d37d94bb..5ae3e7e0bf 100644 --- a/lib/shuttle-server/tests/integration.rs +++ b/lib/shuttle-server/tests/integration.rs @@ -50,10 +50,10 @@ async fn integration() -> std::result::Result<(), Box> { // Create both streams. let (source_stream, destination_stream) = { - let source_subject = Subject::from(format!("{}.shuttle.test.source.>", prefix)); - let source_stream_name = format!("SHUTTLE_TEST_SOURCE_{}", prefix); - let destination_subject = Subject::from(format!("{}.shuttle.test.destination.>", prefix)); - let destination_stream_name = format!("SHUTTLE_TEST_DESTINATION_{}", prefix); + let source_subject = Subject::from(format!("{prefix}.shuttle.test.source.>")); + let source_stream_name = format!("SHUTTLE_TEST_SOURCE_{prefix}"); + let destination_subject = Subject::from(format!("{prefix}.shuttle.test.destination.>")); + let destination_stream_name = format!("SHUTTLE_TEST_DESTINATION_{prefix}"); let source_stream = context .get_or_create_stream(Config { @@ -80,10 +80,9 @@ async fn integration() -> std::result::Result<(), Box> { match Shuttle::new( client, source_stream_clone, - Subject::from(format!("{}.shuttle.test.source.some.inner.*", prefix)), + Subject::from(format!("{prefix}.shuttle.test.source.some.inner.*")), Subject::from(format!( - "{}.shuttle.test.destination.some.inner.messages", - prefix + "{prefix}.shuttle.test.destination.some.inner.messages" )), ) .await @@ -101,10 +100,8 @@ async fn integration() -> std::result::Result<(), Box> { // Publish messages on the source stream to ensure that shuttle works. { - let data_setup_subject = Subject::from(format!( - "{}.shuttle.test.source.some.inner.messages", - prefix - )); + let data_setup_subject = + Subject::from(format!("{prefix}.shuttle.test.source.some.inner.messages")); // Publish many messages to be shuttled. for index in 0..MESSAGE_COUNT { diff --git a/lib/si-aws-config/src/lib.rs b/lib/si-aws-config/src/lib.rs index afc2516852..77af2dce95 100644 --- a/lib/si-aws-config/src/lib.rs +++ b/lib/si-aws-config/src/lib.rs @@ -52,7 +52,7 @@ pub enum AwsConfigError { impl AwsConfigError { fn from_sdk_error(error: SdkError) -> Self { - AwsConfigError::Sts(format!("{:?}", error)) + AwsConfigError::Sts(format!("{error:?}")) } } diff --git a/lib/si-data-acmpca/src/lib.rs b/lib/si-data-acmpca/src/lib.rs index 65c4631d7e..8b411ad0f1 100644 --- a/lib/si-data-acmpca/src/lib.rs +++ b/lib/si-data-acmpca/src/lib.rs @@ -86,7 +86,7 @@ pub enum PrivateCertManagerClientError { impl PrivateCertManagerClientError { fn from_sdk_error(error: SdkError) -> Self { - PrivateCertManagerClientError::AwsPrivateCertManager(format!("{:?}", error)) + PrivateCertManagerClientError::AwsPrivateCertManager(format!("{error:?}")) } } diff --git a/lib/si-data-pg/src/lib.rs b/lib/si-data-pg/src/lib.rs index 91424b4003..681a0dff7a 100644 --- a/lib/si-data-pg/src/lib.rs +++ b/lib/si-data-pg/src/lib.rs @@ -119,7 +119,7 @@ pub enum PgError { #[error("transaction not exclusively referenced when rollback attempted; arc_strong_count={0}")] TxnRollbackNotExclusive(usize), #[error("unexpected row returned: {0:?}")] - UnexpectedRow(PgRow), + UnexpectedRow(Box), } #[remain::sorted] @@ -2537,7 +2537,7 @@ impl PgSharedTransaction { match self.inner.lock().await.borrow_txn().as_ref() { Some(txn) => match txn.query_opt(statement, params).await? { None => Ok(()), - Some(row) => Err(PgError::UnexpectedRow(row)), + Some(row) => Err(PgError::UnexpectedRow(Box::new(row))), }, None => { unreachable!("txn is only consumed with commit/rollback--this is an internal bug") diff --git a/lib/si-data-ssm/src/lib.rs b/lib/si-data-ssm/src/lib.rs index c9920af008..bf9e15d11a 100644 --- a/lib/si-data-ssm/src/lib.rs +++ b/lib/si-data-ssm/src/lib.rs @@ -63,7 +63,7 @@ pub enum ParameterStoreClientError { impl ParameterStoreClientError { fn from_sdk_error(error: SdkError) -> Self { - ParameterStoreClientError::AwsParameterStore(format!("{:?}", error)) + ParameterStoreClientError::AwsParameterStore(format!("{error:?}")) } } diff --git a/lib/si-events-rs/src/xxhash_type.rs b/lib/si-events-rs/src/xxhash_type.rs index 5f7cc1ed5d..014412901a 100644 --- a/lib/si-events-rs/src/xxhash_type.rs +++ b/lib/si-events-rs/src/xxhash_type.rs @@ -182,7 +182,7 @@ macro_rules! create_xxhash_type { impl [<$name Hasher>] { pub fn new() -> Self { - Self(Box::new(::xxhash_rust::xxh3::Xxh3::new())) + Self(Box::default()) } pub fn update(&mut self, input: &[u8]) { diff --git a/lib/si-filesystem/src/lib.rs b/lib/si-filesystem/src/lib.rs index 3ac06c562a..8a44234a57 100644 --- a/lib/si-filesystem/src/lib.rs +++ b/lib/si-filesystem/src/lib.rs @@ -3102,7 +3102,7 @@ impl SiFileSystem { log::trace!("invaliding changeset {change_set_id}"); self_clone.invalidate_change_set(change_set_id).await; } else { - log::error!("{:?}", err); + log::error!("{err:?}"); } } }); diff --git a/lib/si-firecracker/src/disk.rs b/lib/si-firecracker/src/disk.rs index 04b5dd3742..239ac5849b 100644 --- a/lib/si-firecracker/src/disk.rs +++ b/lib/si-firecracker/src/disk.rs @@ -100,7 +100,7 @@ impl FirecrackerDisk { } fn overlay_from_id(id: u32) -> String { - format!("{}{}", OVERLAY_PREFIX, id) + format!("{OVERLAY_PREFIX}{id}") } fn find_loop_device_by_backing_file(backing_file: &Path) -> Result> { @@ -118,7 +118,7 @@ impl FirecrackerDisk { let backing_file_path = path.join("loop").join("backing_file"); if let Ok(contents) = fs::read_to_string(&backing_file_path) { if contents.trim() == backing_file.to_string_lossy() { - return Ok(Some(OsString::from(format!("/dev/{}", loop_name)))); + return Ok(Some(OsString::from(format!("/dev/{loop_name}")))); } } } diff --git a/lib/si-firecracker/src/firecracker.rs b/lib/si-firecracker/src/firecracker.rs index 20d1514d8f..45dfe14357 100644 --- a/lib/si-firecracker/src/firecracker.rs +++ b/lib/si-firecracker/src/firecracker.rs @@ -1,9 +1,6 @@ use std::{ fs::Permissions, - io::{ - Error, - ErrorKind, - }, + io::Error, os::unix::fs::PermissionsExt, path::{ Path, @@ -66,15 +63,15 @@ impl FirecrackerJail { .arg("--exec-file") .arg("/usr/bin/firecracker") .arg("--uid") - .arg(format!("500{}", id)) + .arg(format!("500{id}")) .arg("--gid") .arg("10000") .arg("--netns") - .arg(format!("/var/run/netns/jailer-{}", id)) + .arg(format!("/var/run/netns/jailer-{id}")) .arg("--") .arg("--config-file") .arg("./firecracker.conf"); - let socket = PathBuf::from(&format!("/srv/jailer/firecracker/{}/root/v.sock", id)); + let socket = PathBuf::from(&format!("/srv/jailer/firecracker/{id}/root/v.sock")); Ok(Self { jailer: cmd, @@ -96,8 +93,7 @@ impl FirecrackerJail { .map_err(FirecrackerJailError::Prepare)?; if !output.status.success() { - return Err(FirecrackerJailError::Prepare(Error::new( - ErrorKind::Other, + return Err(FirecrackerJailError::Prepare(Error::other( String::from_utf8(output.stderr) .unwrap_or_else(|_| "Failed to decode stderr".to_string()), ))); @@ -157,8 +153,7 @@ impl FirecrackerJail { // error enum with its own variants and make this a formal variant. Why? We may need // to provide more context and/or capture stdout here. Many script errors end with // empty stderr. - return Err(FirecrackerJailError::Setup(Error::new( - ErrorKind::Other, + return Err(FirecrackerJailError::Setup(Error::other( String::from_utf8(output.stderr) .unwrap_or_else(|_| "Failed to decode stderr".to_string()), ))); diff --git a/lib/si-firecracker/src/stream.rs b/lib/si-firecracker/src/stream.rs index eda09d6f65..29597e0503 100644 --- a/lib/si-firecracker/src/stream.rs +++ b/lib/si-firecracker/src/stream.rs @@ -108,7 +108,7 @@ pub struct TcpStreamForwarder { impl TcpStreamForwarder { pub async fn new() -> Result { let port = DEFAULT_OTEL_PORT; - let addr = format!("127.0.0.1:{}", port); + let addr = format!("127.0.0.1:{port}"); let source = TcpListener::bind(addr) .await .map_err(StreamForwarderError::Tcp)?; diff --git a/lib/si-layer-cache/tests/integration_test/db/cas.rs b/lib/si-layer-cache/tests/integration_test/db/cas.rs index f01d718a03..3b1afa3084 100644 --- a/lib/si-layer-cache/tests/integration_test/db/cas.rs +++ b/lib/si-layer-cache/tests/integration_test/db/cas.rs @@ -382,7 +382,7 @@ async fn stress_test() { let time = tokio::time::Instant::now(); while let Some(res) = write_join_set.join_next().await { if let Err(e) = res { - panic!("Write failed {}", e); + panic!("Write failed {e}"); } } println!("writes are all sent: {:?}", time.elapsed()); @@ -391,7 +391,7 @@ async fn stress_test() { while let Some(res) = read_join_set.join_next().await { if let Err(e) = res { println!("read failed: {:?}", time.elapsed()); - panic!("Read failed {}", e); + panic!("Read failed {e}"); } println!("read succeeded: {:?}", time.elapsed()); } diff --git a/lib/si-pkg/src/spec/attribute_value.rs b/lib/si-pkg/src/spec/attribute_value.rs index 4c906f8c8f..80670cfb00 100644 --- a/lib/si-pkg/src/spec/attribute_value.rs +++ b/lib/si-pkg/src/spec/attribute_value.rs @@ -36,8 +36,8 @@ pub enum KeyOrIndex { impl fmt::Display for KeyOrIndex { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let _ = match self { - KeyOrIndex::Key(key) => write!(f, "[{}]", key), - KeyOrIndex::Index(index) => write!(f, "[{}]", index), + KeyOrIndex::Key(key) => write!(f, "[{key}]"), + KeyOrIndex::Index(index) => write!(f, "[{index}]"), }; Ok(()) } @@ -47,13 +47,13 @@ impl fmt::Display for AttributeValuePath { match self { AttributeValuePath::Prop { path, key_or_index } => { if let Some(attribute_value_index_or_key) = key_or_index { - write!(f, "{}{}", path, attribute_value_index_or_key)? + write!(f, "{path}{attribute_value_index_or_key}")? } else { - write!(f, "{}", path)? + write!(f, "{path}")? } } - AttributeValuePath::InputSocket(path) => write!(f, "{}", path)?, - AttributeValuePath::OutputSocket(path) => write!(f, "{}", path)?, + AttributeValuePath::InputSocket(path) => write!(f, "{path}")?, + AttributeValuePath::OutputSocket(path) => write!(f, "{path}")?, }; Ok(()) } diff --git a/lib/si-pool-noodle/src/instance/cyclone/local_uds.rs b/lib/si-pool-noodle/src/instance/cyclone/local_uds.rs index b3e488024a..fc55416e43 100644 --- a/lib/si-pool-noodle/src/instance/cyclone/local_uds.rs +++ b/lib/si-pool-noodle/src/instance/cyclone/local_uds.rs @@ -110,7 +110,7 @@ pub enum LocalUdsInstanceError { ChildSpawn(#[source] io::Error), /// Cyclone client error. #[error(transparent)] - Client(#[from] ClientError), + Client(#[from] Box), /// Failed to build a container. #[error("failed to build a cyclone container: {0}")] ContainerBuild(#[source] Error), @@ -150,7 +150,7 @@ pub enum LocalUdsInstanceError { TempSocket(#[source] io::Error), /// Cyclone client `watch` endpoint error. #[error(transparent)] - Watch(#[from] WatchError), + Watch(#[from] Box), /// Cyclone client `watch` session ended earlier than expected. #[error("server closed watch session before expected")] WatchClosed, @@ -162,6 +162,18 @@ pub enum LocalUdsInstanceError { WatchShutDown, } +impl From for LocalUdsInstanceError { + fn from(value: ClientError) -> Self { + Box::new(value).into() + } +} + +impl From for LocalUdsInstanceError { + fn from(value: WatchError) -> Self { + Box::new(value).into() + } +} + type Result = result::Result; /// A local Cyclone [`Instance`], managed as a spawned child process, communicating over a Unix diff --git a/lib/si-service/src/startup.rs b/lib/si-service/src/startup.rs index 28a4fd72aa..0cf1a6ecbc 100644 --- a/lib/si-service/src/startup.rs +++ b/lib/si-service/src/startup.rs @@ -58,7 +58,7 @@ pub async fn startup(service: &str) -> Result<(), std::io::Error> { return Ok(()); } - let metadata_candidates = match glob(&format!("/etc/nix-omnibus/{}/*/metadata.json", service)) { + let metadata_candidates = match glob(&format!("/etc/nix-omnibus/{service}/*/metadata.json")) { Ok(iter) => iter, Err(_) => { info!("metadata candidates could not be found for {}", service); diff --git a/lib/si-split-graph/src/lib.rs b/lib/si-split-graph/src/lib.rs index 3593d28aa4..48f2623d15 100644 --- a/lib/si-split-graph/src/lib.rs +++ b/lib/si-split-graph/src/lib.rs @@ -1481,7 +1481,7 @@ where return Err(SplitGraphError::TooManyEdgesOfKind( from_id, direction, - format!("{:?}", kind), + format!("{kind:?}"), )); } diff --git a/lib/si-split-graph/src/tests/mod.rs b/lib/si-split-graph/src/tests/mod.rs index fe91e6d9b0..aa5772cd38 100644 --- a/lib/si-split-graph/src/tests/mod.rs +++ b/lib/si-split-graph/src/tests/mod.rs @@ -373,8 +373,7 @@ fn default_edges() -> SplitGraphResult<()> { } else { assert!( matches!(edge.0, TestEdgeWeight::EdgeB { is_default: true }), - "{:?} should be default target", - default_target + "{default_target:?} should be default target" ); hit_default = true; } diff --git a/lib/veritech-server/src/server.rs b/lib/veritech-server/src/server.rs index 6d296a1fe9..7dff2d526d 100644 --- a/lib/veritech-server/src/server.rs +++ b/lib/veritech-server/src/server.rs @@ -123,7 +123,7 @@ impl Server { let nats = Self::connect_to_nats(config.nats()).await?; let mut nats_config = config.nats().clone(); if let Some(name) = nats_config.connection_name { - nats_config.connection_name = Some(format!("{}-stream", name)); + nats_config.connection_name = Some(format!("{name}-stream")); } let nats_jetstream = Self::connect_to_nats(&nats_config).await?;