Skip to content

Test: release Go-proxy RESTful contract tests verified passing in Go mode - #17468

Open
euvre wants to merge 11 commits into
infiniflow:mainfrom
euvre:go/release-contract-tests
Open

Test: release Go-proxy RESTful contract tests verified passing in Go mode#17468
euvre wants to merge 11 commits into
infiniflow:mainfrom
euvre:go/release-contract-tests

Conversation

@euvre

@euvre euvre commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Aligns Go error codes/messages with the established (Python) RESTful API contract where the Python side is the reasonable/established behavior, and releases the contract tests that now pass in Go-proxy mode (API_PROXY_SCHEME=go).

Go fixes:

  • /chat/completions (non-stream): expected domain failures (missing messages, missing chat_id, unknown session/chat, unauthorized chat) now return HTTP 200 with business codes 101/102/109 via a new common.CodedError, instead of a generic HTTP 500. The non-stream response also includes audio_binary/prompt/created_at to match Python's decorate_answer shape, with metadata captured only from the final pipeline event.
  • /searchbots/related_questions: a missing question is reported with the contract message instead of the Gin validator format; beta-auth failures return code 102 Authorization is not valid!, mirroring Python's login_required(auth_types=AUTH_BETA).
  • PUT /datasets/{id}: dataset_id is validated as a UUID (code 101 Invalid UUID format); nonexistent datasets report lacks permission for dataset (code 102) so existence is not revealed (IDOR), matching Python.
  • POST /system/tokens: accepts an empty request body (all fields optional) instead of HTTP 400.
  • POST /datasets/{id}/documents/parse|stop: empty document_ids returns code 102 \document_ids` is required`.

Released from GO_ONLY_SKIPS (all verified passing against the Go server):

  • test_chat_completion_validation_errors, test_chat_completion_nonstream_with_session, test_chat_completion_nonstream_with_chat_without_session, test_chat_completion_nonstream_without_chat, test_chat_completion_stream_events
  • test_related_questions_contract
  • test_system_tokens_auth_and_crud
  • test_dataset_update_identifier_validation_contract
  • test_documents_list_default_concurrent_and_filters_contract, test_documents_download_requires_auth_and_invalid_id_contract, test_documents_parse_and_stop, test_documents_stop_parse_requires_auth

Tests that still fail in Go mode (unimplemented routes, response-shape mismatches, and ingestion-pipeline parse timeouts) remain skipped.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 28, 2026
@euvre euvre added the ci Continue Integration label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The non-stream chat completion response now includes pipeline-provided audio, prompt, and creation-time metadata, with tests covering final-event metadata and answer accumulation. Go proxy REST contract-test skip groups are updated for route support and document parsing timeout behavior.

Changes

Chat response metadata

Layer / File(s) Summary
Non-stream response metadata and validation
internal/service/chat_session.go, internal/service/chat_session_test.go
Accumulates answer data, takes audio_binary, prompt, and non-zero created_at from the final pipeline result, and tests omitted or intermediate metadata behavior.

Go proxy REST test coverage

Layer / File(s) Summary
Go-only route skip list updates
test/testcases/restful_api/conftest.py
Removes selected chat-completion, document-list, and document-download tests from skip sets while retaining other unsupported-route cases.
Document parsing timeout skip updates
test/testcases/restful_api/conftest.py
Adds parse-matrix and bulk parsing contracts to the timeout skip group and removes stop-parse exemptions.

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

Suggested reviewers: jinhai-cn, haruko386

Poem

A rabbit twitched its whiskers bright,
Metadata hops into the light.
REST tests leap past skips anew,
While parsing guards reshuffle too.
Hop, hop—the pipeline grew!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: releasing Go-proxy REST contract tests in Go mode.
Description check ✅ Passed The description matches the required Summary template and provides sufficient background and scope.

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.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (b7ddf45) to head (a0496a4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17468   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jul 28, 2026

@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/service/chat_session.go`:
- Around line 1695-1703: Update the metadata assignments in the non-stream
response path to run only when result.Final is true, matching the stream path’s
use of result.Final; assign AudioBinary, Prompt, and CreatedAt directly from
that final result, including empty or zero values. Add a regression test
covering conflicting intermediate and final metadata to verify only the final
event’s values are returned.
🪄 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 Plus

Run ID: 5add3f57-8114-424a-8e69-3cae04375875

📥 Commits

Reviewing files that changed from the base of the PR and between ce1f6f9 and ccc60be.

📒 Files selected for processing (2)
  • internal/service/chat_session.go
  • test/testcases/restful_api/conftest.py
💤 Files with no reviewable changes (1)
  • test/testcases/restful_api/conftest.py

Comment thread internal/service/chat_session.go Outdated
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jul 28, 2026
euvre and others added 3 commits July 28, 2026 15:57
- chat completions: return business error codes (101/102/109) with HTTP 200
  for validation, not-found, and authorization failures instead of HTTP 500
- related_questions: validate missing question with the contract message
  instead of the Gin validator format; beta auth failures return code 102
  "Authorization is not valid!" mirroring login_required(auth_types=AUTH_BETA)
- dataset update: validate dataset_id as UUID (code 101); report nonexistent
  datasets as "lacks permission" so existence is not revealed (IDOR)
- system tokens: accept an empty request body when creating a token
- documents parse/stop: reject empty document_ids with code 102
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant