Skip to content

ci(generated-code-checks): Print actionable error message when generated-code-checks detect stale files (resolves #2160).#2161

Merged
junhaoliao merged 2 commits intomainfrom
actionable-errors
May 4, 2026
Merged

ci(generated-code-checks): Print actionable error message when generated-code-checks detect stale files (resolves #2160).#2161
junhaoliao merged 2 commits intomainfrom
actionable-errors

Conversation

@junhaoliao
Copy link
Copy Markdown
Member

@junhaoliao junhaoliao commented Apr 1, 2026

Description

The check-generated step in both clp-docs-generated-code-checks and clp-s-generated-code-checks CI workflows currently fails silently when generated files are out of date. The check uses git status --porcelain ... | grep . > /dev/null && exit 1 || exit 0, which produces a non-zero exit code with no explanatory output — the developer has to read the workflow YAML, understand the git status pipeline, and figure out which task command to run locally.

This PR replaces the silent check in both workflows with an actionable error message that prints:

  • Which files are out of date (git status --porcelain output).
  • The full diff of the stale files (git diff output).
  • The exact task command the developer needs to run to regenerate them.

Additionally, this fixes a minor duplication in the workflows where the paths were duplicated in the git status command.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Scenario 1: Success path — no stale files

Task: Verify the updated check exits cleanly when no generated files are stale.

Command:

bash -c '
stale_files="$(git status --porcelain docs/src/_static/generated)"
if [[ -n "${stale_files}" ]]; then
  echo >&2 "ERROR: The following generated files are out of date:"
  echo >&2 "${stale_files}"
  echo >&2 ""
  echo >&2 "Please run '\''task codegen:openapi'\'' locally and commit the updated files."
  git diff >&2 docs/src/_static/generated
  exit 1
fi
echo "PASS: no stale files detected"
'

Output:

PASS: no stale files detected

Explanation: When git status --porcelain returns an empty string (no modifications), the check exits with code 0 and produces no error output.

Scenario 2: Failure path — stale files detected

Task: Verify the updated check prints an actionable error message, lists stale files, shows the diff, and exits with a non-zero code.

Setup: Created a temporary git repo with a modified generated file to simulate staleness.

Command:

mkdir -p /tmp/test-stale-check && cd /tmp/test-stale-check
git init -q
mkdir -p generated
echo "original" > generated/test.json
git add . && git commit -q -m "init"
echo "modified" > generated/test.json

bash -c '
stale_files="$(git status --porcelain generated)"
if [[ -n "${stale_files}" ]]; then
  echo >&2 "ERROR: The following generated files are out of date:"
  echo >&2 "${stale_files}"
  echo >&2 ""
  echo >&2 "Please run '\''task codegen:openapi'\'' locally and commit the updated files."
  git diff >&2 generated
  exit 1
fi
'
echo "Exit code: $?"

Output:

ERROR: The following generated files are out of date:
 M generated/test.json

Please run 'task codegen:openapi' locally and commit the updated files.
diff --git a/generated/test.json b/generated/test.json
index 4b48dee..2e09960 100644
--- a/generated/test.json
+++ b/generated/test.json
@@ -1 +1 @@
-original
+modified
Exit code: 1

Explanation: When stale files are detected, the check prints the stale file list, the full diff, and the exact command to run, then exits with code 1. This gives the developer all the information they need to resolve the issue without reading the workflow YAML.

Scenario 3: clp-s-generated-code-checks — same behaviour

Task: Verify the clp-s workflow check follows the same pattern with the correct task command (task codegen:clp-s-generate-parsers).

Verification: Read the updated workflow file and confirmed:

  • The git status --porcelain captures both kql/generated and sql/generated paths.
  • The error message references task codegen:clp-s-generate-parsers.
  • The git diff covers both generated directories.

Summary by CodeRabbit

  • Chores
    • Improved CI checks to more reliably detect when generated code is out of date.
    • When stale generated files are found, workflows now emit clearer error messages, list the affected files and show diffs to aid debugging.

…ted-code-checks detect stale files (resolves #2160).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c9ce2569-1941-4b12-938c-76b130750e2c

📥 Commits

Reviewing files that changed from the base of the PR and between 6c17384 and 8d199e6.

📒 Files selected for processing (2)
  • .github/workflows/clp-docs-generated-code-checks.yaml
  • .github/workflows/clp-s-generated-code-checks.yaml

Walkthrough

Two CI workflow files were updated to capture git status --porcelain output into variables and to emit detailed stderr messages and git diff output when generated files are stale, replacing prior grep-based existence checks.

Changes

Cohort / File(s) Summary
CI Workflow Updates
.github/workflows/clp-docs-generated-code-checks.yaml, .github/workflows/clp-s-generated-code-checks.yaml
Replaced piped grep existence checks with capturing git status --porcelain into a variable (stale_files). When non-empty, steps now print detailed error messages to stderr, show the stale file lines and git diff for the generated directories, and exit with code 1.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: improving error messages in generated-code-checks CI workflows when stale files are detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch actionable-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@junhaoliao junhaoliao marked this pull request as ready for review April 1, 2026 19:48
@junhaoliao junhaoliao requested a review from a team as a code owner April 1, 2026 19:48
@junhaoliao junhaoliao added this to the Mid-April 2026 milestone Apr 1, 2026
| grep . > /dev/null \
&& exit 1 \
|| exit 0
run: |-
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

technically we can extract a .github/actions/ action so we don't repeat those two very similar steps. that said, we only have two occurrences of those so the extraction is a bit overdoing things. in the future if we have more such workflow steps we can consider extraction of an action

Copy link
Copy Markdown
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

lgtm.

Copy link
Copy Markdown
Contributor

@gibber9809 gibber9809 left a comment

Choose a reason for hiding this comment

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

LGTM. PR title fine as well.

@junhaoliao junhaoliao merged commit 5350aae into main May 4, 2026
55 checks passed
@junhaoliao junhaoliao deleted the actionable-errors branch May 7, 2026 19:46
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.

3 participants