Skip to content

ci: show the spec diff when the staleness check fails - #43912

Merged
villebro merged 3 commits into
apache:masterfrom
shivamgoel:ci/openapi-drift-show-diff
Sep 5, 2026
Merged

villebro merged 3 commits into
apache:masterfrom
shivamgoel:ci/openapi-drift-show-diff

Conversation

@shivamgoel

@shivamgoel shivamgoel commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Follow-up to #43841. The failure reported only a line count, so an author seeing red had to regenerate locally to find out what actually changed — which is what happened when report_format drifted in #43910.

The diff now renders as markdown on the job summary page, with the --stat headline above it and the regeneration command inline. The full diff stays in a collapsed log group. The summary copy is truncated at 300 lines, since step summaries cap at 1 MiB and a full regeneration runs to tens of thousands of lines — #43788 was 25,334.

TESTING INSTRUCTIONS

Verified by extracting the step body from the workflow and running it under GitHub's shell (bash -e -o pipefail) against a seeded spec:

Case Result
Clean tree exit 0, empty summary
One added property exit 1, whole diff rendered, no truncation note
44,011-line / 880 KB diff exit 1, summary 315 lines / 6.5 KB, truncation note and full-diff group present

The large case matters because it is the size of a full regeneration, and it is where output handling breaks if the diff is streamed through head rather than staged to a file.

# seed a failing case
python -c "import json;p='docs/static/resources/openapi.json';s=json.load(open(p));\
s['components']['schemas']['ReportScheduleRestApi.get_list']['properties']['probe']={'type':'string'};\
json.dump(s,open(p,'w'),sort_keys=True,indent=2)"

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

The failure reported only a line count, so an author had to regenerate locally
to find out what changed. Render the diff to the job summary and keep the full
copy in a collapsed log group.
@bito-code-review

bito-code-review Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Files Excluded

Bito didn't auto-review this change because all changed files are in the exclusion list for automatic reviews. No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the excluded files settings here, or contact your Bito workspace admin at evan@preset.io.

@github-actions github-actions Bot added the github_actions Pull requests that update GitHub Actions code label Sep 5, 2026
Comment thread .github/workflows/check-openapi-spec-drift.yml Outdated
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. When git diff is piped to head, the head command closes the pipe after reading 300 lines, which causes git diff to receive a SIGPIPE signal. Because pipefail is enabled in GitHub Actions, this signal causes the entire command to fail, potentially aborting the script prematurely.

To resolve this, you can use set +o pipefail before the command or redirect the output to a temporary file instead of piping directly to head.

Here is the corrected implementation for the affected block:

              echo '```diff'
              git diff -- "$SPEC" > diff.tmp
              head -300 diff.tmp
              echo '```'
              if [ "$(wc -l < diff.tmp)" -gt 300 ]; then
                echo
                echo '_Truncated at 300 lines; see the job log for the full diff._'
              fi
              rm diff.tmp

I have checked the other comments on this PR, and there are no additional comments to address. Would you like me to perform any further actions?

.github/workflows/check-openapi-spec-drift.yml
echo 'diff' git diff -- "$SPEC" > diff.tmp head -300 diff.tmp echo ''
if [ "$(wc -l < diff.tmp)" -gt 300 ]; then
echo
echo 'Truncated at 300 lines; see the job log for the full diff.'
fi
rm diff.tmp

Piping into `head` let it close the pipe once the diff exceeded the buffer,
SIGPIPE-killing `git diff` under pipefail and aborting the step at exit 141 —
so the summary lost its closing fence and truncation note and the full diff
never printed, precisely when the diff was largest. Staging to a file also
drops two redundant `git diff` runs.
@villebro
villebro merged commit a3aba2a into apache:master Sep 5, 2026
68 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants