Skip to content

fix: correct PR number string conversion and add pagination to GetIssues - #506

Open
saurabhhhcodes wants to merge 1 commit into
agnivo988:mainfrom
saurabhhhcodes:fix/repolyzer-batch-1
Open

fix: correct PR number string conversion and add pagination to GetIssues#506
saurabhhhcodes wants to merge 1 commit into
agnivo988:mainfrom
saurabhhhcodes:fix/repolyzer-batch-1

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Jul 24, 2026

Copy link
Copy Markdown

Two runtime bugs fixed:

  1. Wrong string conversion for PR numbers in collaboration.go (string(rune(pr.Number+'0')) produces incorrect Unicode characters for numbers > 9, e.g., PR ci.yml update #42 → "PR #Z"). Fixed with fmt.Sprintf.

  2. Missing pagination in GetIssues - only fetched the first 100 issues, silently dropping all others. Added full pagination loop.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling when initializing analysis caches, with clearer failure reporting.
    • Improved forecast trend formatting to correctly capitalize the first character, including non-ASCII text.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The analyze command now handles cache initialization failures, while the trends command uses Unicode-aware capitalization for forecast labels.

Changes

Cache initialization handling

Layer / File(s) Summary
Cache error propagation
cmd/analyze.go
Cache initialization errors are wrapped and returned instead of being ignored.

Trend label formatting

Layer / File(s) Summary
Unicode trend capitalization
cmd/trends.go
Forecast trend labels uppercase their first rune using unicode.ToUpper instead of strings.Title.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: tanmayythakare, sujitha-kotyada

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes PR number formatting and issue pagination, but the actual changes are cache error handling and forecast text formatting. Rewrite the title to reflect the real changes, e.g. mention cache initialization error handling and forecast capitalization.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/github/issues.go`:
- Around line 49-52: Update the pagination flow around the `c.get` call in the
issues-fetching method so errors on later pages do not discard previously
accumulated issues. Define and consistently handle an explicit partial-results
contract, or propagate the pagination failure so `cmd/analyze.go` marks the
analysis incomplete instead of replacing the result with an empty slice.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4fa173f3-5009-419e-b1e4-03a400bb90a6

📥 Commits

Reviewing files that changed from the base of the PR and between 59221f9 and 71566e6.

📒 Files selected for processing (3)
  • internal/analyzer/collaboration.go
  • internal/config/settings.go
  • internal/github/issues.go

Comment thread internal/github/issues.go Outdated
Comment on lines +49 to +52
var issues []Issue
if err := c.get(url, &issues); err != nil {
return nil, err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not discard previously fetched issues on later-page errors.

If page 2 or later fails, return nil, err drops all successfully fetched pages. cmd/analyze.go, Lines 229-237, then replaces the result with an empty slice, so analysis can silently report no issues after a transient pagination failure. Make the caller fail/mark the analysis incomplete, or define and handle an explicit partial-results contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/github/issues.go` around lines 49 - 52, Update the pagination flow
around the `c.get` call in the issues-fetching method so errors on later pages
do not discard previously accumulated issues. Define and consistently handle an
explicit partial-results contract, or propagate the pagination failure so
`cmd/analyze.go` marks the analysis incomplete instead of replacing the result
with an empty slice.

@saurabhhhcodes
saurabhhhcodes force-pushed the fix/repolyzer-batch-1 branch from 71566e6 to 06becb3 Compare July 24, 2026 08:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
cmd/trends.go (1)

256-258: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for Unicode first-rune capitalization.

Please cover multi-word ASCII text, non-ASCII leading letters, non-letter leading runes, and the empty-trend fallback (Stable) in cmd/trends_test.go.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/trends.go` around lines 256 - 258, Add regression tests in
cmd/trends_test.go for the capitalization logic around forecast trend labels:
cover multi-word ASCII input, a non-ASCII leading letter, a non-letter leading
rune, and an empty trend that falls back to Stable. Use the existing test
conventions and verify the complete resulting label for each case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/analyze.go`:
- Around line 256-259: Update the cache initialization error path around
cache.NewCache so it calls overallProgress.Finish() before returning the wrapped
cache error, matching the neighboring fatal-error paths and ensuring progress
tracking is completed.
- Around line 256-259: Move the cache.NewCache call and its error handling into
the existing incremental-analysis block in the analyze flow, using cacheInstance
only when incremental is enabled. Keep non-incremental analysis independent of
cache initialization and preserve the existing initialization error propagation
for incremental runs.

---

Nitpick comments:
In `@cmd/trends.go`:
- Around line 256-258: Add regression tests in cmd/trends_test.go for the
capitalization logic around forecast trend labels: cover multi-word ASCII input,
a non-ASCII leading letter, a non-letter leading rune, and an empty trend that
falls back to Stable. Use the existing test conventions and verify the complete
resulting label for each case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c6cd39eb-225d-474b-b8f3-4aed4b3ddc9e

📥 Commits

Reviewing files that changed from the base of the PR and between 71566e6 and 06becb3.

📒 Files selected for processing (2)
  • cmd/analyze.go
  • cmd/trends.go

Comment thread cmd/analyze.go
Comment on lines +256 to +259
cacheInstance, cacheErr := cache.NewCache()
if cacheErr != nil {
return fmt.Errorf("failed to initialize cache: %w", cacheErr)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Finish the progress tracker before returning the cache error.

Neighboring fatal-error paths call overallProgress.Finish(). This new early return does not, so a cache initialization failure can leave the progress UI active or incomplete.

 		cacheInstance, cacheErr := cache.NewCache()
 		if cacheErr != nil {
+			overallProgress.Finish()
 			return fmt.Errorf("failed to initialize cache: %w", cacheErr)
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cacheInstance, cacheErr := cache.NewCache()
if cacheErr != nil {
return fmt.Errorf("failed to initialize cache: %w", cacheErr)
}
cacheInstance, cacheErr := cache.NewCache()
if cacheErr != nil {
overallProgress.Finish()
return fmt.Errorf("failed to initialize cache: %w", cacheErr)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/analyze.go` around lines 256 - 259, Update the cache initialization error
path around cache.NewCache so it calls overallProgress.Finish() before returning
the wrapped cache error, matching the neighboring fatal-error paths and ensuring
progress tracking is completed.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Initialize the cache only for incremental analysis.

cacheInstance is unused unless incremental is enabled, but this now makes every analysis fail when the cache directory cannot be created. Move cache creation inside the if incremental block so non-incremental runs remain independent of cache availability.

Proposed fix
-		cacheInstance, cacheErr := cache.NewCache()
-		if cacheErr != nil {
-			return fmt.Errorf("failed to initialize cache: %w", cacheErr)
-		}
 		// Incremental analysis support
 		if incremental {
+			cacheInstance, cacheErr := cache.NewCache()
+			if cacheErr != nil {
+				return fmt.Errorf("failed to initialize cache: %w", cacheErr)
+			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cacheInstance, cacheErr := cache.NewCache()
if cacheErr != nil {
return fmt.Errorf("failed to initialize cache: %w", cacheErr)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/analyze.go` around lines 256 - 259, Move the cache.NewCache call and its
error handling into the existing incremental-analysis block in the analyze flow,
using cacheInstance only when incremental is enabled. Keep non-incremental
analysis independent of cache initialization and preserve the existing
initialization error propagation for incremental runs.

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.

1 participant