Skip to content

fix(web): add trailing slash to channel list/create API endpoints - #6948

Open
jerzygao wants to merge 1 commit into
QuantumNous:mainfrom
jerzygao:fix/channel-api-trailing-slash
Open

fix(web): add trailing slash to channel list/create API endpoints#6948
jerzygao wants to merge 1 commit into
QuantumNous:mainfrom
jerzygao:fix/channel-api-trailing-slash

Conversation

@jerzygao

@jerzygao jerzygao commented Aug 20, 2026

Copy link
Copy Markdown

📝 变更描述 / Description

The channels admin page returns 404 {"error":{"message":"Invalid URL (GET /api/channel)"...}} when loading the channel list, and the same 404 when creating a channel.

Root cause. getChannels (GET) and createChannel (POST) request /api/channel (no trailing slash), but the backend registers the list/create/update handlers at path: "/" under the /channel group — i.e. /api/channel/ (router/channel-router.go, since #5755). Every other list call in the frontend (/api/user/, /api/token/, /api/option/, /api/group/) — and this file's own updateChannel — already use the trailing-slash form, so they work.

For most groups Gin's RedirectTrailingSlash bridges the no-slash form (301 → slash), but the /channel group (also /user, /subscription/admin) is not bridged in Gin v1.9.1, so the no-slash request falls through to NoRoutecontroller.RelayNotFound → the OpenAI-style 404.

Fix. Add the trailing slash to the two calls to match the rest of the codebase (and updateChannel):

  • GET /api/channelGET /api/channel/
  • POST /api/channelPOST /api/channel/

No backend change required.

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

No existing issue found (searched "channel 404" / "Invalid URL"). Happy to open one first if a maintainer prefers.

✅ 提交前检查项 / Checklist

  • 人工确认: this description was prepared with AI assistance (Claude Code) as an organized summary, not a raw dump; submitter to review/edit before finalizing.
  • 非重复提交: searched existing issues & PRs; no duplicate.
  • Bug fix 说明: no prior issue linked yet (see Related Issue).
  • 变更理解: yes — see root cause above.
  • 范围聚焦: 1 file, 2 lines; no unrelated changes.
  • 本地验证: see proof below.
  • 安全合规: no credentials; trivial string change.

📸 运行证明 / Proof of Work

Running build of main (Gin v1.9.1), unauthenticated probes — a 401 means the route exists (auth middleware ran):

Request Result
GET /api/channel (no slash — what the frontend sent) 404 Invalid URL (GET /api/channel)
GET /api/channel/ (slash) 401 (route exists)
GET /api/user (no slash) 404 (same gap; its frontend uses /api/user/, so the page still works)
GET /api/token (no slash) 301 → /api/token/ (tsr works for this group)

With an admin token, GET /api/channel/ returns 200 with the channel list — which is what the frontend hits after this fix. tsgo -b typecheck passes.


Note: this PR was prepared with AI assistance (Claude Code) under the submitter's direction, including the root-cause analysis and the 2-line fix, both verified locally. The submitter is invited to review/edit.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved channel loading and creation by correcting API endpoint handling.

getChannels (GET) and createChannel (POST) called /api/channel without a trailing slash, inconsistent with every other list endpoint and the channel's own updateChannel, which use /api/channel/. The channel group's no-slash form is not bridged by Gin RedirectTrailingSlash, so these calls fell through to NoRoute (RelayNotFound) and returned 404 on the channels page.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 51684f5d-0288-43bd-ac15-14d8aed573b1

📥 Commits

Reviewing files that changed from the base of the PR and between f116414 and ab1f2c2.

📒 Files selected for processing (1)
  • web/src/features/channels/api.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

The channel listing and creation requests now use /api/channel/ with a trailing slash. Query parameters, request payloads, action configuration, and response handling remain unchanged.

Changes

Channel API updates

Layer / File(s) Summary
Normalize channel endpoint paths
web/src/features/channels/api.ts
getChannels and createChannel now use /api/channel/ while preserving their existing request behavior.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to ab1f2

The change updates channel list and create requests to the backend’s registered trailing-slash endpoints, resolving the reported 404 behavior without broader product impact; no actionable merge-blocking risk remains.

Poem

A rabbit checks the channel door,
Now slashed neatly as before.
List and create pass through bright,
Payloads steady, paths just right.
Hop, hop—the API is light!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the trailing-slash fix for the channel list and create API endpoints.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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