Repository navigation
fix(go-agent): align GitHub and Invoke Canvas components - #16849
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughAdds a configurable GitHub repository search tool and Canvas component with retrieval references, and changes ChangesGitHub search integration
Invoke component contract
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
internal/agent/component/github.go (1)
219-223: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winSHA-1 used for non-security ID hashing — consider a non-crypto hash.
githubHashIntonly derives deterministic numeric IDs for chunk/document identifiers, not a security boundary, so SHA-1's cryptographic weakness isn't exploitable here. Still, usingcrypto/sha1for this will keep tripping SAST tools (see hint below); swapping tohash/fnv(orsha256) removes the recurring flag with a small change.Static analysis flagged this as CWE-327 (broken/risky crypto), but the usage here is non-security ID generation, not signatures/integrity/auth.♻️ Proposed fix: use FNV instead of SHA-1 for non-security ID generation
-import ( - "crypto/sha1" +import ( + "hash/fnv" ... ) func githubHashInt(value string, modulus int64) int64 { - sum := sha1.Sum([]byte(value)) - number := new(big.Int).SetBytes(sum[:]) - return new(big.Int).Mod(number, big.NewInt(modulus)).Int64() + h := fnv.New64a() + _, _ = h.Write([]byte(value)) + return int64(h.Sum64() % uint64(modulus)) }🤖 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/agent/component/github.go` around lines 219 - 223, Replace the SHA-1 digest in githubHashInt with a non-cryptographic hash such as FNV, updating the corresponding import and preserving deterministic modulus-based int64 output. Keep the function’s existing inputs and behavior unchanged for generating numeric identifiers.Source: Linters/SAST tools
internal/agent/tool/github.go (1)
71-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDrop the unused constructor —
NewGitHubToolWithhas no call sites elsewhere in the repo, so keeping it exported only ավելգ the public surface. Remove it or make it unexported.🤖 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/agent/tool/github.go` around lines 71 - 75, Remove the unused exported NewGitHubToolWith constructor from the GitHub tool implementation, or rename it to an unexported symbol if it is needed internally; retain NewGitHubToolWithDefaults and all existing behavior.Source: Coding guidelines
🤖 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/agent/runtime/state.go`:
- Around line 392-422: Update CanvasState.SetRetrievalReferences to merge with
the existing Retrieval["chunks"] and Retrieval["doc_aggs"] instead of replacing
them on each call. Preserve prior chunks, append new chunks, and retain the
first aggregate per document name across all calls while keeping the existing
lock-safe behavior.
In `@internal/agent/tool/registry.go`:
- Around line 198-220: The buildGitHubTool function must enforce GitHub’s
maximum top_n value of 100 before constructing githubParams. After validating
that topN is positive, reject or clamp values above 100, ensuring
NewGitHubToolWithDefaults never receives a larger per-page value.
---
Nitpick comments:
In `@internal/agent/component/github.go`:
- Around line 219-223: Replace the SHA-1 digest in githubHashInt with a
non-cryptographic hash such as FNV, updating the corresponding import and
preserving deterministic modulus-based int64 output. Keep the function’s
existing inputs and behavior unchanged for generating numeric identifiers.
In `@internal/agent/tool/github.go`:
- Around line 71-75: Remove the unused exported NewGitHubToolWith constructor
from the GitHub tool implementation, or rename it to an unexported symbol if it
is needed internally; retain NewGitHubToolWithDefaults and all existing
behavior.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6cf7c9bd-1b05-4d98-8dd7-2452ca000da4
📒 Files selected for processing (9)
internal/agent/component/fixture_stubs.gointernal/agent/component/github.gointernal/agent/component/github_test.gointernal/agent/component/invoke.gointernal/agent/component/invoke_test.gointernal/agent/runtime/state.gointernal/agent/tool/github.gointernal/agent/tool/github_test.gointernal/agent/tool/registry.go
|
LGTM |
Summary
Tests
bash build.sh --test ./internal/agent/tool/...bash build.sh --test ./internal/agent/component/...Note: the untracked go_ragflow_cli file is not part of the PR changes.