fix: best-efforts handling of poisoned (unencoded) Readme descriptions during deserialization#2593
Conversation
URLDecoder.decode() throws IllegalArgumentException when a string contains % not followed by two valid hex digits. Readme descriptions stored as plain text (e.g. "50% faster") hit this when the AssetDeserializer calls decodeContent() during an index search response. Fall back to returning the original string when decoding fails, so a malformed or plain-text description doesn't crash deserialization of the entire batch.
|
Solid defensive fix — worth being explicit about what it does and doesn't address. This catches the symptom safely, but it's worth noting for the record that the underlying issue is upstream: a readme description containing a bare That said, this change is still worth shipping on its own merits:
Two things to keep on the radar so we don't consider this closed:
TL;DR: 👍 to stop the bleeding and contain blast radius — but let's open a follow-up to track down the writer producing un-encoded descriptions. |
What
URLDecoder.decode()throwsIllegalArgumentExceptionwhen it encounters a%not followed by exactly two valid hex digits.AssetDeserializercallsStringUtils.decodeContent()on the description of everyReadmeasset during index search response deserialization. If any Readme in the result batch has plain text like"50% faster"in its description, the exception propagates through Jackson and crashes deserialization of the entire batch — not just the offending asset.Fix
Catch
IllegalArgumentExceptionindecodeContent()and return the original string. Legitimately URL-encoded descriptions (the normal case) continue to decode correctly. Plain-text descriptions that happen to contain%are returned as-is, which is the right behavior, as they were never URL-encoded in the first place.Testing
Added
decodeContentWithLiteralPercent()toStringUtilsTestcovering the two patterns seen in production (%;and% u) plus the null case. ExistingencodeDecodeContent()test confirms the happy path is unaffected.