Skip to content

Fix pull request comment rendering and disable flags - #322

Merged
lelia merged 2 commits into
mainfrom
lelia/ce-381-python-cli-github-pr-comment-leaves-orphaned-elements-empty
Sep 2, 2026
Merged

Fix pull request comment rendering and disable flags#322
lelia merged 2 commits into
mainfrom
lelia/ce-381-python-cli-github-pr-comment-leaves-orphaned-elements-empty

Conversation

@lelia

@lelia lelia commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Two fixes to the pull request comment the CLI posts:

  1. Rendering artifacts. Security comments could render orphaned </blockquote></details> tags as a literal code block, and could leave the "Caution" banner sitting above an alerts table with no rows. A whitespace-only line closes a CommonMark HTML block; optional sections that rendered as empty left one behind inside the table, and because the closing tags after it are indented four or more spaces they were rendered as an indented code block rather than markup. The empty table appeared separately, when a comment's alerts were all resolved by a later commit or ignored by comment.
  2. Comment disable flags. --disable-security-issue and --disable-overview were checked only after testing whether a comment of that type already existed, so they suppressed the first post and then updated that comment on every later run.

Changes

  • Generated comment markup no longer contains blank lines and stays under the indentation that starts a code block.
  • Alert descriptions, suggestions and license findings are collapsed onto a single line, so multi-line API text cannot break the table either.
  • When no alerts are left to report, the comment body is replaced with a short confirmation instead of an empty table. The comment marker is preserved, so a commit that reintroduces an alert updates the same comment rather than posting a second one.
  • @SocketSecurity ignore-all now applies to comments in the pre-2.0.55 Markdown table format. The check was made once per ignore command, and an ignore-all comment produces none, so no rows were removed.
  • The disable flags now mean the CLI does not manage that comment at all. An existing comment is left untouched rather than rewritten, since a body claiming no alerts would be inaccurate when reporting is merely switched off.

Bumps to 2.7.0 rather than a patch, since the disable flags change behavior.

Testing

  • tests/unit/test_pr_comment_rendering.py covers both rendering artifacts, the ignore round trips, and the collapsed body. tests/unit/test_socketcli.py covers the comment write decision, which previously had no harness.
  • Every generated body was rendered through GitHub's /markdown API to confirm the tags are gone; 423 unit and 87 core tests pass.

Fixes CE-381
Fixes CE-427

@lelia
lelia requested a review from a team as a code owner August 28, 2026 00:01

@flowstate Eric Hibbs (flowstate) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

oh and we should add a lint:fix via ruff somewhere in our automation, main is carrying around like 75 formatting issues, nothing major

@lelia lelia changed the title Fix orphaned tags and empty tables in PR comments Fix pull request comment rendering and disable flags Sep 2, 2026
A whitespace-only line closes a CommonMark HTML block. Optional sections that
rendered as empty left one behind inside the alerts table, so the indented
closing tags after it were rendered as a literal code block reading
`</blockquote></details>` instead of markup.

- Drop blank lines from generated comment markup and keep indentation below the
  four spaces that start a code block.
- Collapse alert descriptions, suggestions and license findings onto a single
  line so multi-line API text cannot break the table either.
- Replace the comment body with a short confirmation when no alerts are left to
  report, instead of keeping the caution banner above a table with no rows. The
  comment marker is preserved so the same comment is updated later.
- Apply ignore-all to the pre-2.0.55 Markdown table format. The check was made
  once per ignore command and an ignore-all comment produces none, so no rows
  were removed.

Bumps to 2.6.8.
Both flags were checked only after testing whether a comment of that type was
already on the pull request, so they suppressed the first post and then updated
that comment on every later run. --disable-security-issue in particular kept
refreshing an existing comment with the full alerts table.

The flags now mean the CLI does not manage that comment at all. An existing
comment is left untouched rather than rewritten, since a body claiming no alerts
would be inaccurate when reporting is merely switched off.

Moves the decision into should_write_comment() so it is covered by tests
directly; main_code() had no harness for this block.

Bumps to 2.7.0 rather than a patch, since these flags change behavior.
@lelia
lelia force-pushed the lelia/ce-381-python-cli-github-pr-comment-leaves-orphaned-elements-empty branch from ef831c7 to 48d4330 Compare September 2, 2026 20:55
@lelia
lelia deployed to socket-firewall September 2, 2026 20:55 — with GitHub Actions Active
@lelia
lelia merged commit 717d0af into main Sep 2, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants