Skip to content

[Detail Bug] CLI: bugs show displays dangling em-dash when Fix PR URL is empty #323

Description

@detail-app

Detail Bug Report

https://app.detail.dev/org_5f375fe3-a706-4e9a-a6f7-800f2439b3f6/bugs/bug_a24d4f9b-5acd-47dc-831f-62933c0a3cc8

Introduced in #319 by @tjdammann on Jul 24, 2026

Summary

  • Context: The format_fix_pr function in src/api/types.rs formats the Fix PR for display in the bugs show command.
  • Bug: When the API returns an empty URL string, the function produces #42 (merged) — with a dangling em-dash and trailing space.
  • Actual vs. expected: Actual: #42 (merged) — (looks like rendering failed). Expected: #42 (merged) (clean output matching the card view pattern).
  • Impact: Users see output that appears broken, as if something failed to render. This is confusing and suggests the CLI might have a bug, rather than the data simply lacking a URL.

Code with Bug

pub fn format_fix_pr(fix_pr: &FixPr) -> String {
    format!(
        "#{} ({}) \u{2014} {}",
        fix_pr.pr_number, fix_pr.state, fix_pr.url  // <-- BUG 🔴 unconditionally includes URL
    )
}

Explanation

FixPr.url can be an empty string (OpenAPI schema requires the field but does not enforce minLength). format_fix_pr always appends — {url}, so when url == "" the output ends with a dangling em-dash and trailing space.

Codebase Inconsistency

Elsewhere, the code omits the em-dash when there is no URL (format_linked_issue uses map_or_else to choose a no-URL format), and Bug.to_card() renders fix PRs as #42 (merged) without the URL. format_fix_pr should follow the same conditional formatting behavior.

Failing Test

fn format_fix_pr_with_empty_url() {
    let fix_pr: FixPr = serde_json::from_value(serde_json::json!({
        "prNumber": 42,
        "url": "",
        "state": "merged"
    }))
    .expect("valid FixPr JSON");
    let result = format_fix_pr(&fix_pr);
    assert_eq!(result, "#42 (merged) \u{2014} ");  // <-- proves current output includes dangling em-dash
}

Recommended Fix

Handle empty URLs explicitly and omit the em-dash when fix_pr.url.is_empty():

pub fn format_fix_pr(fix_pr: &FixPr) -> String {
    if fix_pr.url.is_empty() {
        format!("#{} ({})", fix_pr.pr_number, fix_pr.state)
    } else {
        format!("#{} ({}) \u{2014} {}", fix_pr.pr_number, fix_pr.state, fix_pr.url)
    }
}

History

This bug was introduced in commit 79486ad.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions