fix/Improve Komga patch operation robustness#262
fix/Improve Komga patch operation robustness#262gregoryn22 wants to merge 3 commits intoSnd-R:masterfrom
Conversation
…rClientAdapter - Add safe URL handling for links to prevent unsafe URLs - Enhance URL validation to ensure only valid http/https schemes and non-empty hosts are accepted
|
Can you give an example of an url that fails for you? Most of the issues were caused by url encoding and were fixed by using If you want to actually validate an url it's better to use |
|
thanks for the pointers! here's a URL that blew up on the komga side that led to me tracking this down:
Komga responds with So in that case the unencoded i've also hit cases where komga rejects the url with a 400
In those situations the provider is sending things like “link placeholders” or odd strings that look like URLs but don’t meet Komga’s validation rules. My goal with this PR is just to make sure a single bad link from a provider doesn’t cause the entire metadata PATCH to fail |
|
this url will fail |
|
superseded by #276, going to separate the url validation from totalBookCount handling in a future pr |
Summary
This PR improves the robustness of patch operations sent to Komga by adding validation for URLs and handling invalid
totalBookCountvalues. These changes prevent Komga from rejecting metadata updates due to invalid data.Changes
1. URL Validation (
safeUrlOrNullfunction)safeUrlOrNullhelper function that validates URLs before sending them to Komgahttporhttpsschemenullinstead of crashingWhy this is needed: Komga rejects URLs that don't have proper schemes or hosts, which can cause metadata update operations to fail. This validation ensures only valid URLs are sent to Komga.
2. Invalid
totalBookCountHandlingtotalBookCountvalues that are<= 0before sending to KomgaWhy this is needed: Komga rejects
totalBookCountvalues that are zero or negative, which can cause metadata updates to fail. By filtering out invalid values, we ensure the patch operation succeeds even when providers return invalid data.Impact
totalBookCountvaluesTesting
The changes have been tested with:
totalBookCountvalues (0, negative numbers)Files Changed
komf-mediaserver/src/commonMain/kotlin/snd/komf/mediaserver/komga/KomgaMediaServerClientAdapter.kt