Skip to content

fix(tool): normalize code comment metadata enums#481

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
ousamabenyounes:fix/issue-477
Jul 26, 2026
Merged

fix(tool): normalize code comment metadata enums#481
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
ousamabenyounes:fix/issue-477

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Normalizes code_comment category and severity values at the parser boundary so undocumented model output does not silently pass through as canonical metadata. Unknown categories fall back to other, unknown severities fall back to low, valid mixed-case values are canonicalized to lowercase, and the comment content/location are preserved.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Test verification (RED → GREEN)

RED on upstream-base behavior with the new regression test:

--- FAIL: TestParseComments_CategorySeveritySchemaDrift (0.00s)
    code_comment_test.go:218: category = "correctness", want "other"
    code_comment_test.go:221: severity = "info", want "low"
FAIL
FAIL	github.com/open-code-review/open-code-review/internal/tool	0.010s

RED for the OCR review-bot casing counterexample before the lowercase fix:

--- FAIL: TestParseComments_CategorySeverity (0.00s)
    --- FAIL: TestParseComments_CategorySeverity/normalizes_casing (0.00s)
        code_comment_test.go:216: category = "other", want "security"
        code_comment_test.go:219: severity = "low", want "critical"
FAIL
FAIL	github.com/open-code-review/open-code-review/internal/tool	0.006s

GREEN after the fix:

ok  	github.com/open-code-review/open-code-review/internal/tool	0.011s

Full local Go CI replay in golang:1.26.5:

gofmt -s -l .
go mod tidy && git diff --exit-code -- go.mod go.sum
go vet ./...
go test -v -race -count=1 -coverprofile=coverage.out ./...
Total coverage: 81.6%
go build -o /dev/null ./cmd/opencodereview

Cross-compile check started in golang:1.26.5 and built linux/arm64 and darwin/amd64; later targets were blocked by runner disk exhaustion during link (no space left on device).

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Related Issues

Fixes #477

@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 1 issue(s) in this PR.

  • ✅ Successfully posted inline: 1 comment(s)

Comment thread internal/tool/code_comment.go

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101 lizhengfeng101 added the To be merged Merge before the next release label Jul 24, 2026
@tuto221990-byte

Copy link
Copy Markdown

Review current changes

ocr review

Review diff between branches

ocr review --from main --to feature-auth

Review a specific commit

ocr review --commit abc123

@lizhengfeng101
lizhengfeng101 merged commit abfcc86 into alibaba:main Jul 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To be merged Merge before the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate code_comment category and severity at the parser boundary and surface schema drift

4 participants