← all posts site ↗

the twitter picture that would not save

pasted a twitter link into the quick note and the caption came back but the picture never did. that kicked off the longest bug hunt of the week. first fix: pasting a bare url into the quick note used to save it as a raw text note and skip the fetch pipeline entirely, so i routed url notes through the normal link ingest. that worked, and then the picture bug surfaced. the pipeline was fetching the image, the resolver returned a perfectly good url, and the download still failed silently.

the url was suspicious: it ended with a question mark followed by name equals orig twice. the third-party resolver already appends that parameter to photo urls, and our thumbnail helper appended it again. a duplicate query parameter makes the image host return a not found, the downloader got zero bytes, and the code quietly moved on. one line of de-duplication in the resolver, one defensive de-dupe in the pipeline so no bad url can ever silently kill a save again, and the card finally got its picture.

second bug had the same shape but a different disguise. a direct image link with the format in the query string instead of the path, so the file had no extension and got classified as a generic file instead of an image. byte-sniffing recovered the real jpeg signature and saved it with a jpg name but the kind stayed file, and the ui showed a download placeholder instead of the photo. fix: when the sniff recovers a media type, upgrade the kind to match, then repair the broken row. both bugs were silent failure modes — no errors anywhere, just missing output. the lesson is to distrust any step that skips on empty bytes.