Skip to content

Conversation

@mostlygeek
Copy link
Owner

@mostlygeek mostlygeek commented Sep 25, 2025

Fixes #321

Summary by CodeRabbit

  • Bug Fixes
    • Requests to a model’s root path without a trailing slash now redirect to the canonical URL with a trailing slash (e.g., /upstream/model → /upstream/model/).
    • Query parameters are preserved during the redirect.
    • Redirects use permanent status codes (301 for GET/HEAD, 308 for other methods) to improve compatibility with bookmarks and external links.

@coderabbitai
Copy link

coderabbitai bot commented Sep 25, 2025

Walkthrough

Adds a redirect in proxyToUpstream for requests where the upstream path exactly matches a model name and lacks a trailing slash: constructs /upstream/{model}/ (preserving query string) and returns a 301 for GET/HEAD or 308 for other methods. No exported API changes.

Changes

Cohort / File(s) Summary
Upstream model redirect handling
proxy/proxymanager.go
When remainingPath == "/" and upstreamPath has no trailing /, construct /upstream/{searchModelName}/, append original query string if present, and issue a redirect: 301 for GET/HEAD, 308 for other methods; return early. No other logic or exported signatures changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Proxy as ProxyManager
  Note over Client,Proxy: Request path equals model name without trailing slash
  Client->>Proxy: GET/POST /upstream/{model}?q=...
  alt Path == model and no trailing slash
    rect rgb(230,245,255)
      Proxy-->>Client: 301 (GET/HEAD) or 308 (other) Redirect to /upstream/{model}/?q=...
    end
  else Other paths
    Proxy->>Upstream: Forward request
    Upstream-->>Proxy: Response
    Proxy-->>Client: Response
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

bug

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title succinctly identifies the addition of a trailing slash redirect in the proxyToUpstream function, directly reflecting the main change without extraneous details.
Linked Issues Check ✅ Passed The implementation introduces a permanent redirect for requests missing a trailing slash, preserving query parameters and ensuring the upstream path ends with a slash, fulfilling issue #321’s requirements for a 301 redirect and consistent endpoint URLs.
Out of Scope Changes Check ✅ Passed All modifications are confined to the proxyToUpstream logic for handling trailing‐slash redirects and do not introduce unrelated features or alter other behaviors, so no out‐of‐scope changes are present.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch redirect-upstream-issue-321

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ddd48a4 and 05d6b7f.

📒 Files selected for processing (1)
  • proxy/proxymanager.go (2 hunks)
🔇 Additional comments (1)
proxy/proxymanager.go (1)

427-437: Redirect preserves state and semantics

The new path keeps the query string intact and chooses 301 vs 308 based on method, so we avoid dropping navigation state and accidental method downgrades. Looks solid.


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a84926 and ddd48a4.

📒 Files selected for processing (1)
  • proxy/proxymanager.go (2 hunks)

@mostlygeek mostlygeek merged commit 9e3d491 into main Sep 25, 2025
3 checks passed
@mostlygeek mostlygeek deleted the redirect-upstream-issue-321 branch September 25, 2025 23:43
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.

Upstream endpoint should always end with a /

2 participants