fix(web): add trailing slash to channel list/create API endpoints - #6948
fix(web): add trailing slash to channel list/create API endpoints#6948jerzygao wants to merge 1 commit into
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe channel listing and creation requests now use ChangesChannel API updates
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to 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
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
📝 变更描述 / 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) andcreateChannel(POST) request/api/channel(no trailing slash), but the backend registers the list/create/update handlers atpath: "/"under the/channelgroup — 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 ownupdateChannel— already use the trailing-slash form, so they work.For most groups Gin's
RedirectTrailingSlashbridges the no-slash form (301 → slash), but the/channelgroup (also/user,/subscription/admin) is not bridged in Gin v1.9.1, so the no-slash request falls through toNoRoute→controller.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/channel→GET /api/channel/POST /api/channel→POST /api/channel/No backend change required.
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
No existing issue found (searched "channel 404" / "Invalid URL"). Happy to open one first if a maintainer prefers.
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
Running build of
main(Gin v1.9.1), unauthenticated probes — a401means the route exists (auth middleware ran):GET /api/channel(no slash — what the frontend sent)Invalid URL (GET /api/channel)GET /api/channel/(slash)GET /api/user(no slash)/api/user/, so the page still works)GET /api/token(no slash)/api/token/(tsr works for this group)With an admin token,
GET /api/channel/returns200with the channel list — which is what the frontend hits after this fix.tsgo -btypecheck passes.🤖 Generated with Claude Code
Summary by CodeRabbit