fix(notifications): validate URLs and show errors#196
Conversation
📝 WalkthroughWalkthroughAdds upfront notification URL validation (no network calls), tightens ntfy URL error messages to avoid echoing credentials, wires validation into server handlers and test flows, standardizes frontend API error parsing, and updates mutation error callbacks to propagate descriptive toast messages. Changes
Sequence Diagram(s)(no sequence diagrams generated) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)Error: unknown linters: 'modernize', run 'golangci-lint help linters' to see the list of supported linters Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@internal/notifications/ntfy.go`:
- Around line 69-73: The parseNtfyURL function currently only checks topic from
parsed.Path; add a host validation immediately after the topic check (inspect
parsed.Host or parsed.Hostname) and return an error (e.g., "ntfy URL must
include a host") if it's empty so malformed URLs like "ntfy:///topic" are
rejected early before building apiURL; keep the error message generic to avoid
echoing credentials and update any callers to handle the new error path.
In `@internal/server/notification_handlers.go`:
- Around line 43-48: Trim the incoming URL once and reuse the trimmed value for
both validation and persistence: call strings.TrimSpace on input.URL, assign the
result back (or to a local trimmedURL) and then pass that trimmed value to
notifications.ValidateNotificationURL and to whatever code stores input.URL, so
you don't validate/store the untrimmed string; apply the same change to the
other occurrence around the block referencing input.URL (lines ~74-79).
Summary
Why
Testing
pnpm -C web lint(fails on develop; unrelated existing lint errors)pnpm -C web buildgo test ./...Screenshots (if UI)
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Tests