From 53c787b692001cc0e6332e0025e6c6e421f321ad Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 15 Oct 2025 15:21:01 +0800 Subject: [PATCH 1/4] style: fix clippy::missing_errors_doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add # Errors documentation sections to public functions that return Result: - Exec::resolve() - Documents PATH search and shebang parsing errors - ensure_env() - Documents EINVAL on conflicting env values - decode_payload_from_env() - Documents env var, base64, and bincode errors - PreExec::run() - Documents infallible nature - handle_exec() - Documents resolution and env operation errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- crates/fspy_shared_unix/src/exec/mod.rs | 15 +++++++++++++++ crates/fspy_shared_unix/src/payload.rs | 8 ++++++++ crates/fspy_shared_unix/src/spawn/macos.rs | 5 +++++ crates/fspy_shared_unix/src/spawn/mod.rs | 10 ++++++++++ crates/vite_task/src/config/mod.rs | 4 ++-- crates/vite_task/src/fingerprint.rs | 2 +- 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/crates/fspy_shared_unix/src/exec/mod.rs b/crates/fspy_shared_unix/src/exec/mod.rs index 899a8a2328..8255b51f08 100644 --- a/crates/fspy_shared_unix/src/exec/mod.rs +++ b/crates/fspy_shared_unix/src/exec/mod.rs @@ -82,6 +82,13 @@ impl Exec { /// /// * `Ok(())` if resolution succeeds and `self` is updated with resolved paths /// * `Err(nix::Error)` with appropriate errno, like the exec function would return + /// + /// # Errors + /// + /// Returns an error if: + /// - The program is not found in PATH (ENOENT) + /// - The program file cannot be accessed or read + /// - Shebang parsing fails due to I/O errors pub fn resolve( &mut self, mut on_path_access: impl FnMut(PathAccess<'_>), @@ -134,6 +141,14 @@ impl Exec { } } +/// Ensures an environment variable is set to the specified value +/// +/// If the variable doesn't exist, it is added. If it exists with the same value, +/// no change is made. If it exists with a different value, an error is returned. +/// +/// # Errors +/// +/// Returns `EINVAL` if the environment variable already exists with a different value. pub fn ensure_env( envs: &mut Vec<(BString, Option)>, name: impl AsRef, diff --git a/crates/fspy_shared_unix/src/payload.rs b/crates/fspy_shared_unix/src/payload.rs index 3a16658282..9b38518dcc 100644 --- a/crates/fspy_shared_unix/src/payload.rs +++ b/crates/fspy_shared_unix/src/payload.rs @@ -38,6 +38,14 @@ pub fn encode_payload(payload: Payload) -> EncodedPayload { EncodedPayload { payload, encoded_string: encoded_string.into() } } +/// Decodes the fspy payload from the environment variable +/// +/// # Errors +/// +/// Returns an error if: +/// - The environment variable is not found +/// - The base64 decoding fails +/// - The bincode deserialization fails pub fn decode_payload_from_env() -> anyhow::Result { let Some(encoded_string) = std::env::var_os(PAYLOAD_ENV_NAME) else { anyhow::bail!("Environment variable '{}' not found", PAYLOAD_ENV_NAME); diff --git a/crates/fspy_shared_unix/src/spawn/macos.rs b/crates/fspy_shared_unix/src/spawn/macos.rs index f6b3bae3fa..f7ad7e740c 100644 --- a/crates/fspy_shared_unix/src/spawn/macos.rs +++ b/crates/fspy_shared_unix/src/spawn/macos.rs @@ -15,6 +15,11 @@ use crate::{ pub struct PreExec(Infallible); impl PreExec { + /// Runs pre-exec operations + /// + /// # Errors + /// + /// This function never returns an error as the type is `Infallible` pub fn run(&self) -> nix::Result<()> { match self.0 {} } diff --git a/crates/fspy_shared_unix/src/spawn/mod.rs b/crates/fspy_shared_unix/src/spawn/mod.rs index 2209edfa5c..66b81a785b 100644 --- a/crates/fspy_shared_unix/src/spawn/mod.rs +++ b/crates/fspy_shared_unix/src/spawn/mod.rs @@ -18,6 +18,16 @@ use crate::{ payload::EncodedPayload, }; +/// Handles exec command resolution and injection +/// +/// Resolves the program path and prepares the command for execution with +/// appropriate environment variables and hooks. +/// +/// # Errors +/// +/// Returns an error if: +/// - Program resolution fails (from `command.resolve()`) +/// - Environment variable operations fail pub fn handle_exec( command: &mut Exec, config: ExecResolveConfig, diff --git a/crates/vite_task/src/config/mod.rs b/crates/vite_task/src/config/mod.rs index ae900459f5..a81780242b 100644 --- a/crates/vite_task/src/config/mod.rs +++ b/crates/vite_task/src/config/mod.rs @@ -261,10 +261,10 @@ impl std::fmt::Debug for ResolvedTaskCommand { /// /// # Fingerprint Ignores Impact on Cache /// -/// The `fingerprint_ignores` field controls which files are tracked in PostRunFingerprint: +/// The `fingerprint_ignores` field controls which files are tracked in `PostRunFingerprint`: /// - Changes to this config must invalidate the cache /// - Vec maintains insertion order (pattern order matters for last-match-wins semantics) -/// - Even though ignore patterns only affect PostRunFingerprint, the config itself is part of the cache key +/// - Even though ignore patterns only affect `PostRunFingerprint`, the config itself is part of the cache key #[derive(Encode, Decode, Debug, Serialize, Deserialize, PartialEq, Eq, Diff, Clone)] #[diff(attr(#[derive(Debug)]))] pub struct CommandFingerprint { diff --git a/crates/vite_task/src/fingerprint.rs b/crates/vite_task/src/fingerprint.rs index 068f1cc60e..f4296ed73c 100644 --- a/crates/vite_task/src/fingerprint.rs +++ b/crates/vite_task/src/fingerprint.rs @@ -99,7 +99,7 @@ impl PostRunFingerprint { .par_iter() .filter(|(path, _)| { // Filter out paths that match ignore patterns - ignore_matcher.as_ref().map_or(true, |matcher| !matcher.is_match(path)) + ignore_matcher.as_ref().is_none_or(|matcher| !matcher.is_match(path)) }) .flat_map(|(path, path_read)| { Some((|| { From c5ec67afab066f2ba48565eb701113ed97d058c9 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 15 Oct 2025 15:28:56 +0800 Subject: [PATCH 2/4] Update crates/fspy_shared_unix/src/exec/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: LongYinan --- crates/fspy_shared_unix/src/exec/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fspy_shared_unix/src/exec/mod.rs b/crates/fspy_shared_unix/src/exec/mod.rs index 8255b51f08..86d497f1f9 100644 --- a/crates/fspy_shared_unix/src/exec/mod.rs +++ b/crates/fspy_shared_unix/src/exec/mod.rs @@ -86,9 +86,9 @@ impl Exec { /// # Errors /// /// Returns an error if: - /// - The program is not found in PATH (ENOENT) - /// - The program file cannot be accessed or read - /// - Shebang parsing fails due to I/O errors + /// - The program is not found in PATH (`ENOENT`) + /// - The program file cannot be accessed or read (`EACCES`, `EISDIR`, `EIO`) + /// - Shebang parsing fails due to I/O errors (`EIO`) pub fn resolve( &mut self, mut on_path_access: impl FnMut(PathAccess<'_>), From f28df9a18e7a102d9d2a4c9fb3bd3fef3db8e34f Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 15 Oct 2025 15:29:05 +0800 Subject: [PATCH 3/4] Update crates/fspy_shared_unix/src/exec/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: LongYinan --- crates/fspy_shared_unix/src/exec/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/fspy_shared_unix/src/exec/mod.rs b/crates/fspy_shared_unix/src/exec/mod.rs index 86d497f1f9..89f5181441 100644 --- a/crates/fspy_shared_unix/src/exec/mod.rs +++ b/crates/fspy_shared_unix/src/exec/mod.rs @@ -148,7 +148,7 @@ impl Exec { /// /// # Errors /// -/// Returns `EINVAL` if the environment variable already exists with a different value. +/// Returns `Err(nix::Error::EINVAL)` if the environment variable already exists with a different value. pub fn ensure_env( envs: &mut Vec<(BString, Option)>, name: impl AsRef, From 93f8d18b21eef6df7a7e99fecb11d4d4179a4520 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 15 Oct 2025 15:29:26 +0800 Subject: [PATCH 4/4] Update crates/fspy_shared_unix/src/spawn/mod.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: LongYinan --- crates/fspy_shared_unix/src/spawn/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fspy_shared_unix/src/spawn/mod.rs b/crates/fspy_shared_unix/src/spawn/mod.rs index 66b81a785b..b16f714589 100644 --- a/crates/fspy_shared_unix/src/spawn/mod.rs +++ b/crates/fspy_shared_unix/src/spawn/mod.rs @@ -26,8 +26,9 @@ use crate::{ /// # Errors /// /// Returns an error if: -/// - Program resolution fails (from `command.resolve()`) -/// - Environment variable operations fail +/// - Program resolution fails (see [`Exec::resolve`] error variants, such as `ENOENT` (file not found) or `EACCES` (permission denied)) +/// - Environment variable operations fail (e.g., `ensure_env` may return `EINVAL` if an existing value conflicts) +/// - Platform-specific errors from `os_specific::handle_exec` pub fn handle_exec( command: &mut Exec, config: ExecResolveConfig,