Skip to content

Sync/origin main with local7 20260318 - #3300

Closed
Micah123321 wants to merge 7 commits into
QuantumNous:mainfrom
Micah123321:sync/origin-main-with-local7-20260318
Closed

Micah123321 wants to merge 7 commits into
QuantumNous:mainfrom
Micah123321:sync/origin-main-with-local7-20260318

Conversation

@Micah123321

@Micah123321 Micah123321 commented Mar 17, 2026 •

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added automatic fallback mechanisms for legacy protocol support when endpoints don't support standard endpoints.
    • Improved stream compatibility layer for Vertex AI with better plain-text chunk handling.
  • Bug Fixes

    • Enhanced authentication header support for Anthropic channel integrations.
  • Refactor

    • Consolidated Docker image publishing exclusively to GitHub Container Registry (GHCR), removing Docker Hub.
    • Updated Docker Compose configuration to use parameterizable image source with GHCR default.
  • Tests

    • Added comprehensive test coverage for protocol fallback paths and stream compatibility scenarios.

@Micah123321 Micah123321 reopened this Mar 17, 2026
@coderabbitai

coderabbitai Bot commented Mar 17, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d5eedaf-49f0-440c-8f1f-f167672b8024

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed2ea6 and af18d9e.

📒 Files selected for processing (17)
  • .github/workflows/docker-image-alpha.yml
  • .github/workflows/docker-image-arm64.yml
  • .github/workflows/docker-image-ghcr.yml
  • controller/channel-test.go
  • controller/channel.go
  • controller/channel_fetch_models_headers_test.go
  • controller/channel_test_legacy_protocol_test.go
  • docker-compose.yml
  • relay/channel/openai/relay-openai.go
  • relay/channel/openai/relay_openai_stream_compat_test.go
  • relay/channel/vertex/adaptor.go
  • relay/channel/vertex/adaptor_test.go
  • relay/chat_completions_via_responses.go
  • relay/compatible_handler.go
  • relay/compatible_handler_legacy_protocol_test.go
  • relay/responses_handler.go
  • relay/responses_handler_test.go

Walkthrough

This PR consolidates Docker image publishing exclusively to GitHub Container Registry (GHCR), removing Docker Hub support across workflow files. It introduces fallback mechanisms for legacy protocol support in channel testing and response handlers, adds Bearer authentication for Anthropic channels, and updates Vertex AI endpoint URLs with API key validation. Related tests and docker-compose configuration are updated accordingly.

Changes

Cohort / File(s) Summary
Docker Workflows - GHCR Consolidation
.github/workflows/docker-image-alpha.yml, docker-image-arm64.yml, docker-image-ghcr.yml
Refactored multi-registry Docker builds to focus exclusively on GHCR. Removed Docker Hub login, metadata extraction, and manifest steps. Added explicit top-level permissions. New workflow file for native amd64+arm64 GHCR publishing with build_single_arch and create_manifests jobs.
Docker Compose Configuration
docker-compose.yml
Parameterized new-api service image from fixed tag to environment variable with GHCR fallback default.
Controller Layer - Legacy Protocol Fallback
controller/channel-test.go, controller/channel_test_legacy_protocol_test.go
Added conditional fallback to /v1/responses using legacy protocol when channel test encounters non-200 response. New helper function shouldFallbackToResponsesInChannelTest with corresponding unit tests covering fallback decision logic and error handling.
Controller Layer - Anthropic Authentication
controller/channel.go, controller/channel_fetch_models_headers_test.go
Extended buildFetchModelsHeaders to include Bearer authentication alongside Anthropic-specific headers. Added unit tests verifying Bearer auth inclusion and header override behavior for Anthropic channels.
Relay - OpenAI Stream Compatibility
relay/channel/openai/relay-openai.go, relay/channel/openai/relay_openai_stream_compat_test.go
Added plain-text SSE fragment wrapping for Vertex AI compatibility. When plain-text data received, constructs chat.completion.chunk object. Includes helper function looksLikeJSONPayload and unit tests for Vertex AI vs OpenAI behavior.
Relay - Vertex AI Adapter
relay/channel/vertex/adaptor.go, relay/channel/vertex/adaptor_test.go
Updated OpenSource endpoint URL from v1beta1 to v1. Added validation guard rejecting API key credentials in OpenSource mode. Includes unit tests for URL construction and error handling.
Relay - Legacy Protocol Fallback
relay/compatible_handler.go, relay/compatible_handler_legacy_protocol_test.go
Introduced proactive fallback mechanism for endpoints not supporting /v1/chat/completions. New exported function ShouldFallbackToResponsesForLegacyProtocol with internal helper. Includes system prompt re-application, quota adjustment, and unit tests for fallback decision logic.
Relay - Responses Compact Fallback
relay/responses_handler.go, relay/responses_handler_test.go
Added graceful fallback from /v1/responses/compact to /v1/responses on 404 responses. Refactored request body handling to byte slice approach. New helper function shouldFallbackResponsesCompactionToResponses with comprehensive unit tests covering multiple scenarios.
Relay - Chat Completions Wrapper
relay/chat_completions_via_responses.go
Exported new wrapper function ChatCompletionsViaResponses delegating to internal implementation for accessibility across packages.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant Controller as Channel Controller
    participant Relay as Relay Handler
    participant Upstream as Upstream Service
    participant Fallback as Legacy Protocol Handler
    
    Client->>Controller: Channel Test Request
    Controller->>Upstream: Forward to /v1/chat/completions
    Upstream-->>Controller: Non-200 Response (unsupported)
    
    alt shouldFallbackToResponsesInChannelTest = true
        Controller->>Fallback: ChatCompletionsViaResponses
        Fallback->>Upstream: Retry via /v1/responses
        Upstream-->>Fallback: Success Response
        Fallback-->>Controller: Usage + Response
        Controller-->>Client: Success with usage
    else Fallback Not Applicable
        Controller->>Controller: RelayErrorHandler
        Controller-->>Client: Error Response
    end
Loading
sequenceDiagram
    actor Client
    participant Handler as Responses Handler
    participant Upstream as Upstream Service
    participant Fallback as Responses Adapter
    
    Client->>Handler: Request with ResponsesCompact Mode
    Handler->>Upstream: POST /v1/responses/compact
    Upstream-->>Handler: 404 Not Found
    
    alt shouldFallbackResponsesCompactionToResponses = true
        Handler->>Fallback: Reconstruct Request Body
        Fallback->>Upstream: POST /v1/responses (non-compact)
        Upstream-->>Fallback: Success Response
        Fallback-->>Handler: Response Data
        Handler-->>Client: Success
    else Fallback Not Applicable
        Handler-->>Client: 404 Error
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • feat: matrix ci #2013: Overlapping changes to docker-image-alpha.yml workflow consolidating multi-arch builds and removing Docker Hub manifest steps in favor of GHCR-focused publishing.
  • feat: matrix ci #2008: Modifies the same GitHub Actions Docker workflows including multi-arch build matrices and GHCR login/manifest creation patterns.
  • feat: openai response /v1/response/compact #2644: Related changes to relay/responses\_handler.go and controller channel tests implementing fallback logic for /v1/responses compact mode with matching RelayModeResponsesCompact behavior.

Suggested labels

ready to merge

Suggested reviewers

  • seefs001
  • creamlike1024
  • Calcium-Ion

Poem

🐰 From Docker Hub to GHCR we hop,
Legacy protocols backed by a fallback prop,
Vertex wraps plaintext with care,
Anthropic auth floats through the air,
Multi-arch manifests everywhere! 🚀

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

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