sigoden/dufs · error · anyhow::Error

invalid q

Error message

invalid q

What it means

Sentinel validation error in handle_search_dir: the search-directory handler requires the `q` query parameter to be present. It fires when a request reaches the search path without `q` in the URL query string, so there is no term to filter directory entries with.

Solutions

  1. Include a non-empty `q` query parameter, e.g. GET /dir?q=name
  2. If a plain directory listing is intended, omit the search mode entirely instead of sending an empty or missing `q`
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/server.rs:612 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sigoden/dufs@fe7fd564f8 (2026-09-09). Data as JSON: /api/errors/965968980a2c79d7. Report an issue: GitHub.

Appendix: source

Thrown at src/server.rs:612

            user,
            access_paths,
            res,
        )
    }

    async fn handle_search_dir(
        &self,
        path: &Path,
        query_params: &HashMap<String, String>,
        head_only: bool,
        user: Option<String>,
        access_paths: AccessPaths,
        res: &mut Response,
    ) -> Result<()> {
        let mut paths: Vec<PathItem> = vec![];
        let search = query_params
            .get("q")
            .ok_or_else(|| anyhow!("invalid q"))?
            .to_lowercase();
        if search.is_empty() {
            return self
                .handle_ls_dir(path, true, query_params, head_only, user, access_paths, res)
                .await;
        }

        if !head_only {
            let path_buf = path.to_path_buf();
            let hidden = Arc::new(self.args.hidden.to_vec());
            let search = search.clone();

            let search_paths = tokio::spawn(collect_dir_entries(
                access_paths.clone(),
                self.running.clone(),
                path_buf,
                hidden,
                self.args.allow_symlink,

View on GitHub (pinned to fe7fd564f8)