Skip to content

Stream drift issue body to gh via stdin and overflow into comments#305

Open
sdairs wants to merge 3 commits into
mainfrom
issue-304-drift-issue-body
Open

Stream drift issue body to gh via stdin and overflow into comments#305
sdairs wants to merge 3 commits into
mainfrom
issue-304-drift-issue-body

Conversation

@sdairs

@sdairs sdairs commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #304

Today's scheduled drift run (https://github.com/ClickHouse/clickhousectl/actions/runs/29905793331) found 155 actionable findings, but crashed filing the issue: create_issue() passed the rendered body to gh issue create as an argv argument, and with embedded spec JSON fragments the body exceeded Linux's ~128 KiB per-argument limit (OSError: [Errno 7] Argument list too long). No drift issue was filed despite real drift.

Changes to scripts/check-openapi-drift.py:

  • create_issue() now streams the body over stdin with gh issue create --body-file -, removing the argv size ceiling entirely.
  • New split_issue_body() splits bodies exceeding GitHub's 65,536-character limit (which today's body did, so --body-file alone would still have been rejected by the API) into GitHub-sized chunks: the first becomes the issue body, the rest are posted as comments with gh issue comment, so no findings are ever dropped. Chunk boundaries land at the last line outside any ``` fence or <details> block, so a block never straddles the issue/comment boundary. As a fallback, a single block larger than the limit is cut at a line boundary and re-closed to keep the markdown well-formed. Each chunk ends with a "report continues" notice and continuation chunks open with a header linking back to the report above. --dry-run output remains a single untouched document.

Tests added in scripts/tests/test_check_openapi_drift.py: short bodies pass through as a single chunk; multi-section bodies split only between blocks with every fence/<details> balanced per chunk and no line lost; an oversized single block is cut and re-closed; create_issue sends the first chunk via stdin to gh issue create and the remainder to gh issue comment against the created issue's URL, with all content preserved across the calls.

python3 -m unittest discover -s scripts/tests -p 'test_*.py' — 7 tests, all passing.

Note: this only fixes reporting. The 155-finding drift itself still needs remediation once this merges and the next scheduled run files the issue.

🤖 Generated with Claude Code

The scheduled drift check crashed with OSError Errno 7 (Argument list
too long) when 155 findings produced an issue body larger than Linux's
per-argument exec limit, so no drift issue was filed. Pass the body to
`gh issue create` through stdin with `--body-file -`, and truncate
oversized bodies at a line boundary (re-closing any open code fence or
<details> block) to fit GitHub's 65,536-character issue body cap, with
a notice pointing at the --dry-run command for the full report.

Fixes #304

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sdairs
sdairs requested review from iskakaushik and rndD as code owners July 22, 2026 14:10
…ting

Truncating at 65,536 characters silently dropped the tail of large drift
reports. Split the body into GitHub-sized chunks instead, posting the
first as the issue body and the rest as comments so nothing is lost.
Chunk boundaries prefer the last line outside any code fence or
<details> block so a block never straddles the issue/comment boundary;
a single block larger than the limit is still cut mid-block and
re-closed as a fallback.

Fixes #304

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sdairs sdairs changed the title Stream drift issue body to gh via stdin and truncate to GitHub's limit Stream drift issue body to gh via stdin and overflow into comments Jul 22, 2026
Comment thread scripts/check-openapi-drift.py
Comment thread scripts/check-openapi-drift.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dafd712. Configure here.

Comment thread scripts/check-openapi-drift.py Outdated
Comment thread scripts/check-openapi-drift.py Outdated
Comment thread scripts/check-openapi-drift.py Outdated
…ments

- split_issue_body now hard-truncates a single line that alone exceeds
  the chunk budget (visible "… [line truncated]" marker), so every chunk
  is guaranteed <= MAX_ISSUE_BODY_CHARS for any input.
- The continuation notice is only appended when lines actually remain,
  fixing a false "report continues" footer when the forced branch
  consumes the final line.
- create_issue retries a failed gh issue comment once; on double
  failure it posts a best-effort "report incomplete" comment on the
  issue, logs the error, and re-raises so CI still fails loudly instead
  of leaving a silently partial drift report that blocks future runs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread scripts/check-openapi-drift.py
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.

Drift workflow crashes creating large issues: gh body passed via argv exceeds ARG_MAX

1 participant