feat(examples/gitlab): add fail-open category/severity publication controls - #685
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
…ntrols Port the GitHub Action publication policy (alibaba#478/alibaba#529) to the GitLab CI example so MRs can badge findings and optionally route low-signal categories/severities to summary notes without dropping them. Co-authored-by: Cursor <cursoragent@cursor.com>
b920e00 to
a75b737
Compare
lizhengfeng101
left a comment
There was a problem hiding this comment.
Review
Nice port — the fail-open design is solid and tests are thorough (78 cases covers the surface well).
A few things I noticed:
sanitize_metadata gap in route_comment
build_badge runs values through sanitize_metadata (strips control chars), but route_comment just does .strip().lower() on the raw value. So if an LLM spits out "bu\ng" as a category, the badge renders [bug · high] but routing won't match it against CATEGORIES — it stays inline silently.
Fail-open means nothing gets dropped, so it's safe, but it's confusing: the badge says "bug" while routing doesn't recognize it as one. Probably worth running sanitize_metadata in route_comment too:
cat_raw = sanitize_metadata(comment.get("category") if comment else None).strip().lower()
sev_raw = sanitize_metadata(comment.get("severity") if comment else None).strip().lower()Multiple notes per MR could get noisy
When a review has all three flavors (no-line, routed, failed), you'll post 4 separate notes plus inline comments. On a busy MR that's a lot of bot noise. Might be worth collapsing no-line + routed + failed into one note with section headers. Not a blocker, just something to think about for UX.
Minor
- Removing the unused
start_lineassignment from the loop — good cleanup, confirmed it was never passed to the discussion payload. - Two
test_badge_prefixmethods exist across different test classes. Not a conflict in Python but easy to confuse when grepping test names.
Overall LGTM with the sanitize fix as the one actionable item.
Align routing with build_badge so control characters in LLM category/severity values do not desync badge labels from policy matching.
|
Addressed the |
Summary
examples/gitlab_ci/post_review.py).[category · severity]badges on inline and summary findings, plus optionalOCR_ROUTE_SEVERITY_BELOW/OCR_ROUTE_CATEGORIESrouting that moves matching findings to summary notes without dropping them.Test plan
python3 examples/gitlab_ci/post_review_test.py(78 tests)OCR_ROUTE_SEVERITY_BELOW=mediumandOCR_ROUTE_CATEGORIES=style,documentation,testsecurity/highfindings still land as inline discussions withsuggestion:-0+0Routed to summary…reason and Before/After detailsMade with Cursor