Skip to content

fix(pr): pr describe drops angle brackets in a code span #3637

Closed as not planned

Description

@dan-petty

Problem Description

devops pr describe <issue> --summary <text> reads the section Why of the proposal. It removes each HTML-like tag from that text, also inside a code span. The text origin/<default> in a code span becomes origin/. The body then names a wrong ref, and the command prints no warning.

The cause is proposal_why in src/devops_cli/roadmap/pull_describe.py. It calls safe_text of src/devops_cli/roadmap/stage_change.py, and safe_text calls sanitize_text. An explicit --why does not go through proposal_why, so the same text stays whole.

Reproduction Steps

  1. Write the section Why of a proposal with the text: The plan check lists the files of origin/<default>.
  2. Run uv run devops pr describe <issue> --summary "read the tree once".
  3. Read the body that the command prints.

Expected vs Actual Behavior

Expected: the body holds origin/<default> as written, or the command refuses the text and names the tag.

Actual: the body holds origin/, and the command exits 0 with no warning.

Environment Diagnostics

Found while delivering #3430 on origin/main 66a8a63.

Proposed Solution

Keep the text of a code span as it is. A code span cannot ping a person or link a page, so it needs no sanitizing. Add a test that a Why with origin/<default> in a code span reaches the body whole.

Pre-Submission Checklist

  • I checked that this issue holds no credential or private data.
  • I searched the open and closed issues for pr describe and found no duplicate.

Proposed design

Problem statement

devops pr describe builds the body from the Why section of a proposal. proposal_why passes that text to safe_text, which calls sanitize_text. The sanitizer removes an HTML-like tag inside a code span, so origin/<default> becomes origin/. The fix keeps the text of a code span as written and adds a test for it.

Acceptance criteria

Requirement: Code span keeps angle brackets

The proposal Why text SHALL keep every character inside a Markdown code span.

Scenario: Why with origin/<default>

  • WHEN The section Why holds the text with origin/<default> in a code span.
  • THEN proposal_why returns the text with origin/<default> unchanged.

Requirement: Tag outside a code span is removed

The sanitizer SHALL remove an HTML-like tag that is outside every code span.

Scenario: Tag outside code span

  • WHEN sanitize_text receives <b>bold</b> and origin/<default> with no code span around the tag.
  • THEN The result holds bold and origin/<default> and no <b> tag.

Requirement: Tag-like text inside a code span is kept

The sanitizer MUST keep tag-like text that sits inside a code span.

Scenario: Code span with <default>

  • WHEN sanitize_text receives a code span that holds <default> and <i>text</i> outside it.
  • THEN The result holds the code span unchanged and no <i> tag.

Requirement: Pull request body holds the whole ref

devops pr describe SHALL write the whole code span of the proposal Why into the pull request body.

Scenario: Describe reads a proposal Why

  • WHEN describe_pull reads a proposal whose Why holds origin/<default> in a code span.
  • THEN The body holds origin/<default> and the command prints no warning.

Requirement: Explicit why is unchanged

describe_pull SHALL keep an explicit why text as it is.

Scenario: Explicit why with a code span

  • WHEN describe_pull receives why with origin/<default> in a code span.
  • THEN The body holds origin/<default> unchanged.

Existing Tool Considered

No check has run. markdown-it-py parses Markdown code spans, but it supplies no sanitizer for Markdown source. It would add a dependency for one inline rule. The change builds a small backtick-run scanner: about 2,000 tokens to build, keep and fix it, and about 1 hour.

Key questions

  • Does proposal_why pass the Why text through safe_text?: Yes. proposal_why calls safe_text, and safe_text calls sanitize_text. [sources: src/devops_cli/roadmap/pull_describe.py:159, src/devops_cli/roadmap/stage_change.py]
  • Which function should skip sanitizing inside a code span?: sanitize_text in src/devops_cli/roadmap/refine.py should skip tag removal inside a code span. Every caller then gets the same safe rule. (best practice) [sources: src/devops_cli/roadmap/refine.py, src/devops_cli/roadmap/pull_describe.py:159, src/devops_cli/roadmap/stage_change.py, src/devops_cli/roadmap/alternatives.py]
    • Chosen: sanitize_text. It is the single sanitizer, so the rule protects safe_text, refine and alternatives.
    • Rejected: proposal_why only. It leaves the same defect in other callers of safe_text and sanitize_text.
    • Rejected: safe_text only. Refine and alternatives still remove tags inside code spans.
  • How should sanitize_text find the text of a code span?: It should scan runs of backticks. A run of N backticks opens a span, and the next run of N backticks closes it. It must sanitize only the text outside those spans. (best practice) [sources: openspec/changes/archive/2026-10-28-2478-refine-outside-author/design.md, src/devops_cli/roadmap/refine.py]
    • Chosen: Backtick-run scanner. It follows the GFM code span rule and adds no dependency.
    • Rejected: markdown-it-py token stream. It adds a parser dependency and a renderer for one inline rule.
    • Rejected: Regular expression for paired backticks. It mishandles a run of two or more backticks and text that holds a backtick.
  • Should a tag outside a code span still be removed with no warning?: Yes. The change keeps the current sanitization outside code spans and adds no new warning. The defect is the removal inside a code span. (best practice) [sources: src/devops_cli/roadmap/refine.py, src/devops_cli/roadmap/pull_describe.py]
    • Chosen: Keep current behavior outside code spans. It fixes the reported loss and keeps every existing caller's output.
    • Rejected: Refuse text that holds a tag outside a code span. It changes behavior for every caller and needs a new error path.
    • Rejected: Warn on each removed tag. It adds output to a command that prints only the title and body.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-07: partly.
Tool: markdown-it-py (https://pypi.org/project/markdown-it-py), MIT License, last activity 2026-05-07, maintained.

Activity

  1. added
    source/agent
    type/bug
    scope/pr
    status/new
    value/medium
    effort/low
    on Nov 5, 2026
  2. dan-petty commented on Nov 5, 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 fix prefix of the title gives the type.
    • Scope: scope/pr. The (pr) scope of the title gives the scope.
    • Priority: P2-Medium. The command prints a wrong ref name with no warning, but only for code spans in the Why section.
    • Value: Medium. Users who read the pr describe output see a broken ref and may act on it.
    • Effort: Low. The cause is identified and the fix is to skip code spans in the sanitizing path.
    • Related: fix(roadmap): refine keeps the angle-bracket text of a code span #3504, which asks for a different change. Both report sanitize_text dropping angle brackets inside code spans, but the candidate targets the pr describe command and #3504 targets the refine command.
  3. added
    priority/p2-medium
    on Nov 5, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 6, 2026
  5. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at ae881d6 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Alternatives check: partly

    Reason: The web searches returned no provider answer, so the check rests on the package facts: markdown-it-py is an open, maintained Python Markdown parser that tokenizes inline code spans, which is the hard part of telling origin/<default> inside backticks from a real HTML-like tag. It supplies no sanitizer for Markdown source, so the project would still need its own token walk and a new dependency for one inline rule, which is why the issue's design already weighed and set it aside; it therefore covers only the code-span detection part of the need, not the fix to sanitize_text/proposal_why itself.

    Tool: markdown-it-py (https://pypi.org/project/markdown-it-py)

    • License: MIT License
    • Last activity: 2026-05-07
    • Maintained: yes

    Covers:

    • Parses Markdown into inline tokens, including code spans, so backtick runs are recognized per the Markdown rule
    • Open, maintained Python library with a current release

    Lacks:

    • No sanitizer for Markdown source: stripping HTML-like tags outside code spans would still be the project's own code
    • Would add a parser dependency for a single inline rule
    • Does not change sanitize_text, safe_text or proposal_why, which is where the reported loss happens

    Tools considered:

    Searches run:

    • Python Markdown parser to keep inline code spans unchanged sanitize HTML, results: 0
    • Python library parse Markdown code spans markdown-it-py, results: 0
    • markdown-it-py code span inline rule, results: 0
    • mistune python markdown parser, results: 0
    • markdown-it-py, results: 0
    • python markdown code span scanner library, results: 0
    • markdown-it-py token inline code span API, results: 0

    Sources:

    Checked on 2026-11-07. A person decides what this means for the item. The check changes no label and closes no issue.

  7. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Pull request #3711 (396962e63, the fix of #3504) supersedes this issue. That pull request merged on 2026-11-06, after this issue was filed on origin/main 66a8a63e.

    Since #3711, sanitize_text changes the < of a tag into &lt; only outside code. A tag in a code span or a code block stays as it is. proposal_why calls safe_text, and safe_text calls sanitize_text, so devops pr describe gets the same rule.

    Evidence on origin/main cc19a87a7:

    • proposal_why on a proposal whose section Why holds The plan check lists the files of `origin/<default>`. returns that text unchanged.
    • sanitize_text("<b>bold</b> and origin/<default>", set()) returns &lt;b>bold&lt;/b> and origin/&lt;default>. A tag outside code shows as text, with all its words.
    • sanitize_text keeps the text of a code span as it is, also with a double backtick: Use ``origin/<default>`` here stays the same.
    • tests/roadmap/refine/test_roadmap_refine_sanitize.py::test_sanitize_text_writes_the_code_in_the_models_text_as_it_is covers a tag in a code span, in a code block and in a span with two backticks.
    • The spec openspec/specs/roadmap-refine/spec.md holds the requirement "Refine shows a tag of the model's text as text".

    No change is necessary. I close this issue as not planned.

  8. removed
    status/ready
    on Nov 12, 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/lowpriority/p2-mediumscope/prsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions