mirror of
https://github.com/go-shiori/shiori.git
synced 2026-04-24 22:15:52 +03:00
[PR #1102] fix: handle errors better for duplicated urls #987
Labels
No labels
component:backend
component:builds
component:builds
component:extension
component:frontend
component:readability
database
database:mysql
database:postgres
database:sqlite
feature:ebooks
github_actions
good first issue
hacktoberfest
note:duplicate?
note:fixed?
note:out-of-scope?
os:windows
priority:high
priority:low
pull-request
resolution:as-intended
resolution:cant-reproduce
resolution:duplicate
resolution:fixed
resolution:wontfix
tag:TBD
tag:big-task
tag:help-wanted
tag:huge-data
tag:meta
tag:more-info
tag:next
tag:no-stale
tag:requires-migrations
tag:research
tag:security 🛡️
tag:stale
tag:waiting-for-assignee
type:bug
type:documentation
type:enhancement
type:meta
type:ux
user:cli
user:web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shiori#987
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/go-shiori/shiori/pull/1102
Author: @rept0id
Created: 4/30/2025
Status: 🔄 Open
Base:
master← Head:master📝 Commits (10+)
ea80ae6error handling / URL already exists88f595flocal-only binding for docker-compose.yml where neededb5d7247...67b5d29URLs without prefix928827dtypo. return err for internal/core/url.go:Parsec4440afUpdate internal/core/url.go8bf20b8Update internal/webserver/handler-api.go34bd8e0...e7858c1...7b82fca...📊 Changes
5 files changed (+454 additions, -3 deletions)
View changed files
📝
internal/core/url.go(+53 -3)➕
internal/core/url_test.go(+262 -0)➕
internal/http/response/error.go(+5 -0)📝
internal/webserver/handler-api.go(+34 -0)➕
internal/webserver/handler-api_test.go(+100 -0)📄 Description
This is my first pull request for this project and I'm coming ambitious. Please, show some understanding.
A. Duplicate URLs
So, I noticed that in general, adding a bookmark with a URL that already exists, results in very weird error messages.
The whole case here is that for less tech savvy people, such errors make the project look like it's broken, while in reality I find it to be very stable and mature. Don't catch me wrong, but a tech savvy person my one day try to add again a URL that already added maybe some months ago and "JSON/UNKNOWN ERROR" is not something this person gets.
Let's say first, that panicking is not the best option. Specially if something is so simple as that a URL is just a duplicate. Imagine that other people may use the same deployment and they requests may fail, just because another person made a request for a duplicate URL.
For more serious errors, panicking may be optimal instead of keeping working wrongly. This is not the case here.
Changes :
Thank you for your time !
B. Changed structure of docker-compose.yml.
C. URLs without "http://" or "https://" prefix.
Sometimes, someone needs to add a URL that he didn't copied pasted from the browser and wrote it by hand.
If this person doesn't add a "http://" or "https://" prefix, again that someone was getting "Unknown error occurred."
Some people doesn't even know what "https" is and other people, like me, just want to write a URL like "google.com" and not write the "https" part, like we can do in all of the modern browsers.
P.S.
About part A :
For "ResponseHttpError" in our model, I made a file "responses" for all this in our model, there other people can add other standard responses too.
Please, I don't know how to express this in our codebase, but the responses.go in the model that I added, is not for whatever responses different endpoints return, but for some standard responses like an error response in our case.
I believe and I've seen that there are other standard responses coming in the way, so I guess this will be handful for everyone.
Maybe, just maybe, I should had named this "standardResponses.go" or just write a comment there, but to be fair I noticed that the rest of the files had one simple word as a name, so I decided to not over-engineer by myself and see the opinions of the rest of you ! Let's over-engineer all together at least. ;)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.