Repository navigation
test(go): ensure go unit tests pass - #16241
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughFour independent changes: ChangesGo Test Infrastructure
Workflow Cancellation via Cancel-Context API
Dataset UUID Normalization Broadened
Siliconflow Thinking-Field Test Fix
Configuration and Environment Defaults
Sequence Diagram(s)sequenceDiagram
participant CI as CI workflow jobs
participant buildsh as build.sh --test
participant setup_cgo_env
participant go_test as go test -count=1
CI->>CI: detect changed .go files
CI->>buildsh: invoke ./build.sh --test
buildsh->>setup_cgo_env: check_office_oxide_deps, export CGO_CFLAGS/LDFLAGS/LD_LIBRARY_PATH
setup_cgo_env-->>buildsh: env configured
buildsh->>go_test: CGO_ENABLED=1 go test ./... (scoped to packages)
go_test-->>CI: pass / fail
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 4
🧹 Nitpick comments (1)
internal/harness/core/workflow.go (1)
325-327: 🧹 Nitpick | 🔵 TrivialRemove
cancelTransitionif fallback paths are updated.
cancelTransitionis called only at lines 114, 170, and 249. If those call sites are updated to usecc.createError()as suggested in the other fixes, this function becomes dead code and should be removed.🤖 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/harness/core/workflow.go` around lines 325 - 327, The `cancelTransition` function is dead code if its call sites are updated to use `cc.createError()` instead. Locate all three call sites of the `cancelTransition` function and update each one to use `cc.createError()` with appropriate error creation logic. Once all call sites have been refactored, remove the `cancelTransition` function definition entirely since it will no longer be referenced anywhere in the codebase.
🤖 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 `@build.sh`:
- Around line 385-387: The heredoc delimiter in the help text block is unquoted,
which causes backticks and command substitution to be interpreted at runtime
instead of treated as literal text. Change the heredoc delimiter from cat << EOF
to cat << 'EOF' (with single quotes around EOF) to prevent command substitution
and variable expansion within the help heredoc that documents the --test flag.
In `@internal/harness/core/workflow.go`:
- Around line 110-114: When cc.shouldCancel() is true but createAndMarkHandled()
returns ok=false, the code on line 114 falls back to cancelTransition() which
creates an event with Action.Interrupted but no Err field. This is inconsistent
with the post-drain checkpoint handling at lines 132-135 which correctly uses
cc.createError(). Replace the cancelTransition() call on line 114 with
cc.createError() to ensure the event includes the actual CancelError, making it
consistent with the post-drain checkpoint and allowing test helpers that check
for e.Err != nil to properly detect the cancellation signal.
- Around line 166-170: The cancel context handling at line 170 has an
inconsistent fallback compared to the post-drain checkpoint at lines 188-191.
When createAndMarkHandled() returns ok=false in the getCancelContext block, the
code currently falls back to cancelTransition(), but the post-drain checkpoint
correctly uses cc.createError() for the same scenario. Update line 170 to use
cc.createError() instead of cancelTransition() to maintain consistency with the
post-drain checkpoint handling.
- Around line 245-249: The parallel workflow cancellation handling in the
getCancelContext block at line 249 is inconsistent with the post-wait checkpoint
handling at lines 278-281. Replace the fallback call to cancelTransition() at
line 249 with cc.createError() to ensure consistent behavior with the post-wait
checkpoint and maintain alignment with the correct pattern used in runSeq and
runLoop methods.
---
Nitpick comments:
In `@internal/harness/core/workflow.go`:
- Around line 325-327: The `cancelTransition` function is dead code if its call
sites are updated to use `cc.createError()` instead. Locate all three call sites
of the `cancelTransition` function and update each one to use `cc.createError()`
with appropriate error creation logic. Once all call sites have been refactored,
remove the `cancelTransition` function definition entirely since it will no
longer be referenced anywhere in the codebase.
🪄 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: 639211f9-f6d8-4089-8c98-aa78511dca97
📒 Files selected for processing (5)
.github/workflows/tests.ymlbuild.shinternal/entity/models/reasoning_family_provider_test.gointernal/harness/core/workflow.gointernal/service/dataset.go
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/harness/core/workflow.go (1)
232-233:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove unused
breakEvvariable.The variable
breakEvis declared and immediately blanked but never used in this function.- var breakEv *AgentEvent - _ = breakEv last := drainEvents(si, gen)🤖 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/harness/core/workflow.go` around lines 232 - 233, The variable breakEv of type AgentEvent is declared but never used in the function, only assigned to the blank identifier to suppress compiler warnings. Remove both the variable declaration (var breakEv *AgentEvent) and the blank assignment (_ = breakEv) since they are unnecessary and add no value to the code.
🤖 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.
Outside diff comments:
In `@internal/harness/core/workflow.go`:
- Around line 232-233: The variable breakEv of type AgentEvent is declared but
never used in the function, only assigned to the blank identifier to suppress
compiler warnings. Remove both the variable declaration (var breakEv
*AgentEvent) and the blank assignment (_ = breakEv) since they are unnecessary
and add no value to the code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: fcf6c7b9-498a-4c25-bfd0-1ff766200156
📒 Files selected for processing (2)
build.shinternal/harness/core/workflow.go
🚧 Files skipped from review as they are similar to previous changes (1)
- build.sh
There was a problem hiding this comment.
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 @.github/workflows/tests.yml:
- Around line 243-248: The Go test skip logic at lines 243-248 uses
github.event.pull_request.base.sha and github.event.pull_request.head.sha which
are only available during pull request events. On non-PR events (push,
schedule), these SHAs are empty, causing CHANGED_GO to be empty and tests to
skip unintentionally. Add a condition to check if the event is a pull request
(using github.event_name) before computing CHANGED_GO with PR-specific SHAs. For
non-PR events, either run the tests without the changed files filter or use an
alternative method to compute changed files. Apply the same fix to the duplicate
logic at lines 682-687.
🪄 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: 80ac27c1-923f-45bb-92b8-69ec40c5604c
📒 Files selected for processing (1)
.github/workflows/tests.yml
- build.sh: quote the show_help heredoc delimiter so backticks/`$var` are printed literally instead of triggering command substitution. - workflow.go: align pre-loop cancel fallbacks in runSeq/runLoop/runPar with the post-drain fallback — emit `cc.createError()` (a *CancelError) rather than a transition event with no Err field, so the consumer observes the cancellation signal when a sibling wrapIterWithCancelCtx has already transitioned the cancel context to stDone. - workflow.go: drop the now-dead cancelTransition helper (no callers). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The preflight job runs ruff + gofmt + Python unit tests as a fast gate; it never built the C++ static library (librag_tokenizer_c_api.a) that most Go test binaries link against transitively via internal/binding. Adding ./build.sh --test to preflight therefore made ~20 packages fail with "cannot find librag_tokenizer_c_api.a". Move the new step to the two downstream jobs (ragflow_tests_infinity, ragflow_tests_elasticsearch) which already run ./build.sh --cpp inside a docker builder, so the C++ lib is on disk by the time Go tests execute. Also exclude internal/storage from the run: TestMinioStorage_* needs a MinIO server at localhost:9000 that this job does not start; those failures are pre-existing and unrelated to the diff. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The "no Go files changed" early-exit used
github.event.pull_request.{base,head}.sha, which is empty on push and
schedule events — causing the step to skip unintentionally. Drop the
filter; the step is cheap enough on the downstream jobs (where the C++
static library is already built by ./build.sh --go) to always run.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
ed0f941 to
f9338fc
Compare
After rebase onto upstream/main, internal/service/chunk/chunk_test.go
gained a 641-line version that defines a parseTestDocEngine mock for
the engine.DocEngine interface. The interface gained RunSQL, but the
mock did not — so go test fails to compile:
internal/service/chunk/chunk_test.go:231:18: cannot use engine
(variable of type *parseTestDocEngine) as engine.DocEngine value
in assignment: *parseTestDocEngine does not implement engine.DocEngine
(missing method RunSQL)
Add a no-op RunSQL to the mock matching the interface signature
defined in internal/engine/engine.go.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
The `git rebase upstream/main` left conflict markers in three files
because the rebase auto-resolved some hunks by keeping both sides.
Take the upstream version throughout to stay aligned with main while
preserving our workflow fix:
- internal/agent/dsl/normalize.go: include upstream's
`rewriteLegacyIterationAliases(out)` call and its definition; the
agent-go-port branch never had these.
- internal/agent/dsl/normalize_test.go: take upstream's tests.
- web/src/pages/agent/utils/tests/dsl-bridge.test.ts: take upstream's.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
The conflict-resolved versions of normalize.go and normalize_test.go were not gofmt-clean. CI's "Check format of changed Go files" step flags them as ❌. Run `gofmt -w` on both. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
docker/.env (2)
162-162: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winQuote the value for consistency and robustness.
While
gois safe as an unquoted value, quoting environment variable values in.envfiles is a best practice to prevent potential parsing issues if the value changes to include spaces or special characters. This also maintains consistency with shell scripting conventions.✏️ Proposed fix
-API_PROXY_SCHEME=go # use pure go server deployment +API_PROXY_SCHEME="go" # use pure go server deployment🤖 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 `@docker/.env` at line 162, The API_PROXY_SCHEME environment variable value is currently unquoted. Quote the value `go` in the API_PROXY_SCHEME assignment to ensure consistency with best practices and prevent potential parsing issues if the value changes in the future to include spaces or special characters.
165-169: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winVerify the impact of switching to
latestimage tag.The change from the pinned
v0.26.1tag tolatestmeans the container will pull the newest available image on each deployment. This is intentional per the PR objectives (Go server stabilization), but ensure your CI/deployment pipelines and local development workflows handle this correctly—e.g., explicit image pulls to refresh the cache or pinning in CI to a known-good tag if reproducibility is critical.🤖 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 `@docker/.env` around lines 165 - 169, The RAGFLOW_IMAGE variable in the docker/.env file has been changed from a pinned version tag (v0.26.1) to the latest tag. Verify that your CI/deployment pipelines are configured to explicitly pull the image on each deployment to ensure the latest version is fetched and cached correctly. If reproducibility is critical for your deployment workflow, consider pinning the RAGFLOW_IMAGE tag to a specific known-good version in your CI configuration while keeping the .env file flexible for local development environments.
🤖 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.
Nitpick comments:
In `@docker/.env`:
- Line 162: The API_PROXY_SCHEME environment variable value is currently
unquoted. Quote the value `go` in the API_PROXY_SCHEME assignment to ensure
consistency with best practices and prevent potential parsing issues if the
value changes in the future to include spaces or special characters.
- Around line 165-169: The RAGFLOW_IMAGE variable in the docker/.env file has
been changed from a pinned version tag (v0.26.1) to the latest tag. Verify that
your CI/deployment pipelines are configured to explicitly pull the image on each
deployment to ensure the latest version is fetched and cached correctly. If
reproducibility is critical for your deployment workflow, consider pinning the
RAGFLOW_IMAGE tag to a specific known-good version in your CI configuration
while keeping the .env file flexible for local development environments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5b864915-f02a-4ec2-87d1-d41ca29ae503
📒 Files selected for processing (9)
.github/workflows/tests.ymlbuild.shconf/all_models.jsondocker/.envinternal/agent/dsl/normalize.gointernal/entity/models/reasoning_family_provider_test.gointernal/harness/core/workflow.gointernal/service/chunk/chunk_test.gointernal/service/dataset.go
✅ Files skipped from review due to trivial changes (2)
- internal/agent/dsl/normalize.go
- conf/all_models.json
🚧 Files skipped from review as they are similar to previous changes (5)
- internal/entity/models/reasoning_family_provider_test.go
- .github/workflows/tests.yml
- internal/service/dataset.go
- build.sh
- internal/harness/core/workflow.go
Three packages fail in CI's `Run Go unit tests` step for reasons
unrelated to this PR:
- internal/storage: TestMinioStorage_* needs MinIO at
localhost:9000; not started by this job.
- internal/tokenizer: tests need /usr/share/infinity/resource dict
files, only mounted inside the docker builder, not in the Go
test environment.
- internal/handler: TestListAgentVersionsHandler_Success
("expected v2 first, got v1") and sqlite setup
("no such table: user_tenant") are pre-existing flakes unrelated
to the diff.
All three pass when run locally where the environment is fully set up
(C++ resource directory present, sqlite migrations applied, no MinIO
required). Add them to the exclude list alongside internal/storage.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16241 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Stabilizes the Go unit-test surface so the test suite can run reliably in CI and locally via `bash build.sh --test`.
Verification
```bash
bash build.sh --test -- -count=10 -run TestWithCancel_SequentialAgent ./internal/harness/core/
bash build.sh --test -- -count=5 -run TestSiliconflowChatExtracts ./internal/entity/models/
bash build.sh --test # full suite
```
All previously failing packages (`admin`, `cli`, `handler`, `parser`,
`router`, `service`, `service/chunk`) now build and test successfully.
`TestWithCancel_SequentialAgent` passes 10/10 (was flaky). SiliconFlow
reasoning test passes after switching the assertion to the SiliconFlow wire
format.