Skip to content

Commit d42f8dd

Browse files
snowmeadclaude
andcommitted
fix: Fix CI workflow failures - formatting and test compilation errors
- Run cargo fmt --all to fix formatting issues across multiple files - Fix test_user_agent_set: add missing None parameter to download_crate call - Fix test_problematic_crate_download: add missing None parameter to download_crate call Resolves CI failures in both Check and Lint job (formatting) and Unit Tests job (compilation errors). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent db97a77 commit d42f8dd

File tree

7 files changed

+222
-83
lines changed

7 files changed

+222
-83
lines changed

rust-docs-mcp/src/cache/docgen.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ impl DocGenerator {
4141
}
4242

4343
/// Generate documentation for a crate
44-
pub async fn generate_docs(&self, name: &str, version: &str, progress_callback: Option<ProgressCallback>) -> Result<PathBuf> {
44+
pub async fn generate_docs(
45+
&self,
46+
name: &str,
47+
version: &str,
48+
progress_callback: Option<ProgressCallback>,
49+
) -> Result<PathBuf> {
4550
tracing::info!(
4651
"DocGenerator::generate_docs starting for {}-{}",
4752
name,

rust-docs-mcp/src/cache/downloader.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ impl CrateDownloader {
115115
}
116116

117117
/// Download a crate from crates.io
118-
async fn download_crate(&self, name: &str, version: &str, progress_callback: Option<ProgressCallback>) -> Result<PathBuf> {
118+
async fn download_crate(
119+
&self,
120+
name: &str,
121+
version: &str,
122+
progress_callback: Option<ProgressCallback>,
123+
) -> Result<PathBuf> {
119124
// Check if already cached
120125
if self.storage.is_cached(name, version) {
121126
tracing::info!("Crate {}-{} already cached", name, version);
@@ -582,7 +587,7 @@ mod tests {
582587

583588
// Test that download doesn't fail with 403
584589
// Note: This is an integration test that requires internet access
585-
match downloader.download_crate("serde", "1.0.0").await {
590+
match downloader.download_crate("serde", "1.0.0", None).await {
586591
Ok(path) => {
587592
assert!(path.exists());
588593
println!("Successfully downloaded crate to: {path:?}");
@@ -608,7 +613,7 @@ mod tests {
608613
let downloader = CrateDownloader::new(storage);
609614

610615
match downloader
611-
.download_crate("google-sheets4", "6.0.0+20240621")
616+
.download_crate("google-sheets4", "6.0.0+20240621", None)
612617
.await
613618
{
614619
Ok(path) => {

rust-docs-mcp/src/cache/service.rs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ impl CrateCache {
5454
// Check if crate is downloaded but docs not generated
5555
if !self.storage.is_cached(name, version) {
5656
tracing::info!("Crate {}-{} not cached, downloading", name, version);
57-
self.download_or_copy_crate(name, version, source, None).await?;
57+
self.download_or_copy_crate(name, version, source, None)
58+
.await?;
5859
} else {
5960
tracing::info!(
6061
"Crate {}-{} already cached, skipping download",
@@ -144,7 +145,8 @@ impl CrateCache {
144145

145146
// Check if crate is downloaded
146147
if !self.storage.is_cached(name, version) {
147-
self.download_or_copy_crate(name, version, source, None).await?;
148+
self.download_or_copy_crate(name, version, source, None)
149+
.await?;
148150
}
149151

150152
// Generate documentation for the specific workspace member
@@ -230,8 +232,15 @@ impl CrateCache {
230232
}
231233

232234
/// Generate JSON documentation for a crate
233-
pub async fn generate_docs(&self, name: &str, version: &str, progress_callback: Option<crate::cache::downloader::ProgressCallback>) -> Result<PathBuf> {
234-
self.doc_generator.generate_docs(name, version, progress_callback).await
235+
pub async fn generate_docs(
236+
&self,
237+
name: &str,
238+
version: &str,
239+
progress_callback: Option<crate::cache::downloader::ProgressCallback>,
240+
) -> Result<PathBuf> {
241+
self.doc_generator
242+
.generate_docs(name, version, progress_callback)
243+
.await
235244
}
236245

237246
/// Generate JSON documentation for a workspace member
@@ -332,7 +341,8 @@ impl CrateCache {
332341
) -> Result<PathBuf> {
333342
// Check if crate is already downloaded
334343
if !self.storage.is_cached(name, version) {
335-
self.download_or_copy_crate(name, version, source, None).await?;
344+
self.download_or_copy_crate(name, version, source, None)
345+
.await?;
336346
}
337347

338348
self.storage.source_path(name, version)
@@ -819,27 +829,39 @@ impl CrateCache {
819829
// It's a workspace, get the members and return workspace response
820830
match WorkspaceHandler::get_workspace_members(&cargo_toml_path) {
821831
Ok(members) => {
822-
let response = self.generate_workspace_response(&crate_name, &version, members, &source, false);
832+
let response = self.generate_workspace_response(
833+
&crate_name,
834+
&version,
835+
members,
836+
&source,
837+
false,
838+
);
823839
return response.to_json();
824840
}
825841
Err(e) => {
826-
return CacheResponse::error(format!("Failed to get workspace members: {e}")).to_json();
842+
return CacheResponse::error(format!("Failed to get workspace members: {e}"))
843+
.to_json();
827844
}
828845
}
829846
}
830847

831848
// Not a workspace - generate docs
832849
// Update to doc generation stage
833850
if let (Some(tm), Some(tid)) = (&task_manager, &task_id) {
834-
tm.update_stage(tid, crate::cache::task_manager::CachingStage::GeneratingDocs).await;
851+
tm.update_stage(
852+
tid,
853+
crate::cache::task_manager::CachingStage::GeneratingDocs,
854+
)
855+
.await;
835856
tm.update_step(tid, 1, "Running cargo rustdoc").await;
836857
}
837858

838859
match self.generate_docs(&crate_name, &version, None).await {
839860
Ok(_) => {
840861
// Update to indexing stage
841862
if let (Some(tm), Some(tid)) = (&task_manager, &task_id) {
842-
tm.update_stage(tid, crate::cache::task_manager::CachingStage::Indexing).await;
863+
tm.update_stage(tid, crate::cache::task_manager::CachingStage::Indexing)
864+
.await;
843865
tm.update_step(tid, 1, "Creating search index").await;
844866
}
845867

rust-docs-mcp/src/cache/task_formatter.rs

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ pub fn format_single_task(task: &CachingTask) -> String {
8080
let stage_info = if let Some(stage) = &task.stage {
8181
let step_str = if let Some(step) = task.current_step {
8282
let total = stage.total_steps();
83-
let desc = task.step_description.as_ref()
83+
let desc = task
84+
.step_description
85+
.as_ref()
8486
.map(|d| format!(": {}", d))
8587
.unwrap_or_default();
8688
format!("\n**Step**: {} of {}{}", step, total, desc)
@@ -263,7 +265,8 @@ pub fn format_task_list(tasks: Vec<CachingTask>) -> String {
263265
}
264266
}
265267

266-
let total = in_progress.len() + completed.len() + failed.len() + cancelled.len() + pending.len();
268+
let total =
269+
in_progress.len() + completed.len() + failed.len() + cancelled.len() + pending.len();
267270

268271
// Build summary
269272
let mut output = String::from("# Caching Operations\n\n");
@@ -339,7 +342,9 @@ pub fn format_task_list(tasks: Vec<CachingTask>) -> String {
339342
output.push_str("- **Cancel tasks**: Use `cache_operations` with task_id and cancel: true for each task\n");
340343
}
341344
if !completed.is_empty() || !failed.is_empty() || !cancelled.is_empty() {
342-
output.push_str("- **Clear all completed/failed/cancelled**: `cache_operations({clear: true})`\n");
345+
output.push_str(
346+
"- **Clear all completed/failed/cancelled**: `cache_operations({clear: true})`\n",
347+
);
343348
}
344349

345350
output
@@ -355,7 +360,12 @@ fn format_task_summary(task: &CachingTask) -> String {
355360

356361
let mut output = format!(
357362
"### Task: `{}`\n**Crate**: {}-{} \n**Source**: {}{} \n**Status**: {} \n",
358-
task.task_id, task.crate_name, task.version, task.source_type, source_info, task.status.display()
363+
task.task_id,
364+
task.crate_name,
365+
task.version,
366+
task.source_type,
367+
source_info,
368+
task.status.display()
359369
);
360370

361371
match task.status {
@@ -365,30 +375,59 @@ fn format_task_summary(task: &CachingTask) -> String {
365375

366376
if let Some(step) = task.current_step {
367377
let total = stage.total_steps();
368-
let desc = task.step_description.as_ref()
378+
let desc = task
379+
.step_description
380+
.as_ref()
369381
.map(|d| format!(": {}", d))
370382
.unwrap_or_default();
371383
output.push_str(&format!("**Step**: {} of {}{} \n", step, total, desc));
372384
}
373385
}
374-
output.push_str(&format!("**Started**: {} \n", format_timestamp(task.started_at)));
375-
output.push_str(&format!("**Elapsed**: {}\n\n", format_duration(task.elapsed_secs())));
386+
output.push_str(&format!(
387+
"**Started**: {} \n",
388+
format_timestamp(task.started_at)
389+
));
390+
output.push_str(&format!(
391+
"**Elapsed**: {}\n\n",
392+
format_duration(task.elapsed_secs())
393+
));
376394
output.push_str("**Actions**:\n");
377-
output.push_str(&format!("- Cancel: `cache_operations({{task_id: \"{}\", cancel: true}})`\n", task.task_id));
395+
output.push_str(&format!(
396+
"- Cancel: `cache_operations({{task_id: \"{}\", cancel: true}})`\n",
397+
task.task_id
398+
));
378399
}
379400
TaskStatus::Pending => {
380-
output.push_str(&format!("**Started**: {} \n", format_timestamp(task.started_at)));
401+
output.push_str(&format!(
402+
"**Started**: {} \n",
403+
format_timestamp(task.started_at)
404+
));
381405
output.push_str("\n**Actions**:\n");
382-
output.push_str(&format!("- Cancel: `cache_operations({{task_id: \"{}\", cancel: true}})`\n", task.task_id));
406+
output.push_str(&format!(
407+
"- Cancel: `cache_operations({{task_id: \"{}\", cancel: true}})`\n",
408+
task.task_id
409+
));
383410
}
384411
TaskStatus::Completed => {
385-
output.push_str(&format!("**Duration**: {} \n", format_duration(task.elapsed_secs())));
386-
output.push_str(&format!("**Completed**: {}\n\n", format_timestamp(task.completed_at.unwrap_or(task.started_at))));
412+
output.push_str(&format!(
413+
"**Duration**: {} \n",
414+
format_duration(task.elapsed_secs())
415+
));
416+
output.push_str(&format!(
417+
"**Completed**: {}\n\n",
418+
format_timestamp(task.completed_at.unwrap_or(task.started_at))
419+
));
387420
output.push_str("**Actions**:\n");
388-
output.push_str(&format!("- Clear: `cache_operations({{task_id: \"{}\", clear: true}})`\n", task.task_id));
421+
output.push_str(&format!(
422+
"- Clear: `cache_operations({{task_id: \"{}\", clear: true}})`\n",
423+
task.task_id
424+
));
389425
}
390426
TaskStatus::Failed => {
391-
output.push_str(&format!("**Duration**: {} \n", format_duration(task.elapsed_secs())));
427+
output.push_str(&format!(
428+
"**Duration**: {} \n",
429+
format_duration(task.elapsed_secs())
430+
));
392431
if let Some(error) = &task.error {
393432
// Truncate long errors for list view
394433
let error_preview = if error.len() > 100 {
@@ -399,14 +438,29 @@ fn format_task_summary(task: &CachingTask) -> String {
399438
output.push_str(&format!("**Error**: {}\n\n", error_preview));
400439
}
401440
output.push_str("**Actions**:\n");
402-
output.push_str(&format!("- View details: `cache_operations({{task_id: \"{}\"}})`\n", task.task_id));
403-
output.push_str(&format!("- Clear: `cache_operations({{task_id: \"{}\", clear: true}})`\n", task.task_id));
441+
output.push_str(&format!(
442+
"- View details: `cache_operations({{task_id: \"{}\"}})`\n",
443+
task.task_id
444+
));
445+
output.push_str(&format!(
446+
"- Clear: `cache_operations({{task_id: \"{}\", clear: true}})`\n",
447+
task.task_id
448+
));
404449
}
405450
TaskStatus::Cancelled => {
406-
output.push_str(&format!("**Duration**: {} \n", format_duration(task.elapsed_secs())));
407-
output.push_str(&format!("**Cancelled**: {}\n\n", format_timestamp(task.completed_at.unwrap_or(task.started_at))));
451+
output.push_str(&format!(
452+
"**Duration**: {} \n",
453+
format_duration(task.elapsed_secs())
454+
));
455+
output.push_str(&format!(
456+
"**Cancelled**: {}\n\n",
457+
format_timestamp(task.completed_at.unwrap_or(task.started_at))
458+
));
408459
output.push_str("**Actions**:\n");
409-
output.push_str(&format!("- Clear: `cache_operations({{task_id: \"{}\", clear: true}})`\n", task.task_id));
460+
output.push_str(&format!(
461+
"- Clear: `cache_operations({{task_id: \"{}\", clear: true}})`\n",
462+
task.task_id
463+
));
410464
}
411465
}
412466

@@ -434,7 +488,10 @@ pub fn format_clear_result(tasks: Vec<CachingTask>) -> String {
434488
}
435489

436490
let mut output = String::from("# Tasks Cleared\n\n");
437-
output.push_str(&format!("Successfully cleared {} task(s) from memory:\n\n", tasks.len()));
491+
output.push_str(&format!(
492+
"Successfully cleared {} task(s) from memory:\n\n",
493+
tasks.len()
494+
));
438495

439496
for task in tasks {
440497
let status_str = match task.status {

rust-docs-mcp/src/cache/task_manager.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ impl CachingStage {
8989
/// Get total number of steps for this stage
9090
pub fn total_steps(&self) -> u8 {
9191
match self {
92-
CachingStage::Downloading => 1, // Single step: download
93-
CachingStage::GeneratingDocs => 2, // 1. Run rustdoc, 2. Save docs
94-
CachingStage::Indexing => 3, // 1. Load docs, 2. Create index, 3. Commit
95-
CachingStage::Completed => 1, // Single step: complete
92+
CachingStage::Downloading => 1, // Single step: download
93+
CachingStage::GeneratingDocs => 2, // 1. Run rustdoc, 2. Save docs
94+
CachingStage::Indexing => 3, // 1. Load docs, 2. Create index, 3. Commit
95+
CachingStage::Completed => 1, // Single step: complete
9696
}
9797
}
9898
}
@@ -277,7 +277,12 @@ impl TaskManager {
277277
}
278278

279279
/// Update task step
280-
pub async fn update_step(&self, task_id: &str, step: u8, description: impl Into<String>) -> bool {
280+
pub async fn update_step(
281+
&self,
282+
task_id: &str,
283+
step: u8,
284+
description: impl Into<String>,
285+
) -> bool {
281286
if let Some(mut task) = self.tasks.get_mut(task_id) {
282287
task.set_step(step, description);
283288
true

0 commit comments

Comments
 (0)