Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gtars-bbcache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/databio/gtars"

[dependencies]
biocrs = "0.1.0"
reqwest = { version = "0.12.15", features = ["blocking"] }
ureq = "3.1.4"
shellexpand = "3"
tabled = "0.20.0"
dirs = "6.0.0"
Expand Down
9 changes: 7 additions & 2 deletions gtars-bbcache/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::{Context, Ok, Result, anyhow};
use biocrs::biocache::BioCache;
use biocrs::models::{NewResource, Resource};

use reqwest::blocking::get;
use ureq::get;
use std::fs::{File, create_dir_all, read_dir, remove_dir, remove_file};
use std::io::{BufRead, BufReader, Error, ErrorKind, Write};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -367,7 +367,12 @@ impl BBClient {
fn download_bedset_data(&self, bedset_id: &str) -> Result<Vec<String>> {
let bedset_url = format!("{}/v1/bedset/{}/bedfiles", self.bedbase_api, bedset_id);

let response = get(&bedset_url)?.text()?;
let response = get(&bedset_url)
.call()
.map_err(|e| anyhow!("Failed to GET {}: {}", bedset_url, e))?
.body_mut()
.read_to_string()
Comment on lines +373 to +374
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .body_mut().read_to_string() pattern is incorrect for ureq. The read_to_string() method from std::io::Read requires a mutable String buffer as an argument (e.g., read_to_string(&mut buffer)), but this code doesn't provide one.

For ureq 3.x, the correct pattern is to use .into_string() which consumes the response and returns Result<String, Error>:

let response = get(&bedset_url)
    .call()
    .map_err(|e| anyhow!("Failed to GET {}: {}", bedset_url, e))?
    .into_string()
    .map_err(|e| anyhow!("Failed to read response body for {}: {}", bedset_url, e))?;

This is more idiomatic, handles errors properly, and avoids the need for the intermediate .body_mut() call.

Suggested change
.body_mut()
.read_to_string()
.into_string()

Copilot uses AI. Check for mistakes.
.map_err(|e| anyhow!("Failed to read response body for {}: {}", bedset_url, e))?;

let json: serde_json::Value = serde_json::from_str(&response)?;

Expand Down