Skip to content

fix(roadmap): refine sanitizing breaks the model's code spans and misses references that GitHub links #2525

Description

@dan-petty

Problem Description

sanitize_text in src/devops_cli/roadmap/refine.py, merged in #2507 for #2478, does not stop all the links and cross-repository references that GitHub makes from the model's text. In some cases it makes a new link from text that GitHub did not link before.

  1. It does not put an owner/repo#N reference in a code span when the reference is in underscore emphasis (_cli/cli#1_, __cli/cli#1__), at the end of an italic phrase (_Depends on cli/cli#1_), or after a slash (x/cli/cli#1). GitHub links each one and records a backlink on the issue of the other repository.
  2. It adds backticks inside a code span that holds other text. The added backtick closes the span early, so a www. link, a reference, a handle or a URL that was code becomes text that GitHub links. The www. and reference patterns are new in fix(roadmap): a refine round leaves an outside account issue to a person, and refine neutralizes comment openers, www links and cross-repository references #2507; the handle and URL patterns have the same defect.
  3. It does not wrap a www. link after > (a block quote) or at the start of a table cell, and it does not wrap a URL with a scheme in capitals. GitHub links all of them.
  4. A wrapped link pairs with a lone backtick of the model's text, and the link is then outside code.

The &lt; that refine writes for <! inside a code span stays: split_record finds the record block, and refine finds its markers, in the raw text, which knows no code span. A reviewer of #2507 reported it; it is the trade-off that the design of #2478 records.

Reproduction Steps

On main at e6230dc, run:

uv run python -c "from devops_cli.roadmap.refine import sanitize_text as s; print([s(t, set()) for t in ['A _cli/cli#1_ B', 'C x/cli/cli#1 D __cli/cli#1__ E', 'Run \`curl www.example.com\` here', 'Run \`see other/repo#1 now\` here', 'Ask \`ping @alice now\`', '>www.example.com', '|www.example.com|', 'Read HTTPS://example.com/a', 'A \`b www.example.com c']])"

Render each output with uv run devops gh api -X POST markdown -f mode=gfm -f context=dan-petty/devops-cli -f text='<output>'.

Expected vs Actual Behavior

Expected: GitHub shows each link, handle and reference as code, and text that was code stays as it is.

Actual:

  • A _cli/cli#1_ B stays as it is; GitHub renders <em><a class="issue-link ...">cli/cli#1</a></em>. The same occurs for __cli/cli#1__, _Depends on cli/cli#1_ and x/cli/cli#1.
  • Run `curl www.example.com` here becomes Run `curl `www.example.com`` here, which renders as <code>curl </code>www.example.com`` here, so GitHub links www.example.com. Run `see other/repo#1 now` here becomes Run `see `other/repo#1` now` here, which renders the reference outside code.
  • >www.example.com, |www.example.com| and Read HTTPS://example.com/a stay as they are, and GitHub links each of them.
  • A `b www.example.com c becomes A `b `www.example.com` c: the first two backticks make a code span, and www.example.com is outside code.

Environment Diagnostics

devops-cli 0.10.1, Python 3.14.10, Linux 6.18 (WSL2), markdown-it-py 4.2.0.

Logs, Traces, or Terminal Output

'A _cli/cli#1_ B' -> 'A _cli/cli#1_ B'
'C x/cli/cli#1 D __cli/cli#1__ E' -> 'C x/cli/cli#1 D __cli/cli#1__ E'
'Run `curl www.example.com` here' -> 'Run `curl `www.example.com`` here'
'Run `see other/repo#1 now` here' -> 'Run `see `other/repo#1` now` here'
'Ask `ping @alice now`' -> 'Ask `ping `@alice` now`'
'>www.example.com' -> '>www.example.com'
'|www.example.com|' -> '|www.example.com|'
'Read HTTPS://example.com/a' -> 'Read HTTPS://example.com/a'
'A `b www.example.com c' -> 'A `b `www.example.com` c'

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #2507

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/medium
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The sanitization logic has multiple defects that produce incorrect output.
    • Priority: P2-Medium. The bugs cause GitHub to render unintended links and break code spans, but they do not expose credentials or allow remote code execution.
    • Value: Medium. Users see broken markdown and unintended live links in roadmap issues, which undermines trust in the rendered output.
    • Effort: Medium. Multiple pattern cases need fixing in one function, but the scope is contained to sanitize_text.
    • Related: fix(roadmap): refine leaves an issue from an outside account waiting on a person, and neutralizes comment markers, bare links and cross-repository references #2478, which asks for a different change. Both concern sanitizing model text in refine.py, but #2478 asks for the sanitization feature while the candidate reports bugs in its implementation.
  3. added
    priority/p2-medium
    on Oct 28, 2026
  4. added a commit that references this issue on Oct 28, 2026
  5. removed
    status/new
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions