Skip to content

Hotfix: image search inserts a verified, saved image - #46

Merged
stupidgiraffe merged 3 commits into
mainfrom
hotfix/image-search-insert-20261009
Oct 9, 2026
Merged

stupidgiraffe merged 3 commits into
mainfrom
hotfix/image-search-insert-20261009

Conversation

@stupidgiraffe

Copy link
Copy Markdown
Owner

Bug

Manual image search selection stored only a third-party URL and immediately reported success. Hotlink-blocked/expired image links left blank flashcards.

Fix

  • Embed the exact selected image through the existing image search API, validating against fresh provider results before downloading.
  • Use a provider thumbnail if original download is blocked; otherwise show an explicit failure instead of fake success.
  • Verify/decode/compress and persist the image before displaying the success toast; preserve metadata and side placement.
  • Disable double-clicks during insertion, surface progress/failures.
  • Add 5 API regression tests covering selected candidate, URL validation/SSRF boundary, thumbnail fallback, download errors, and search compatibility.

Validation

Local patch passed build and 164 primary-tree tests (exclude unrelated stale .worktrees test discovery). GitHub branch was created on latest main; only relevant image insertion code was patched, keeping recent theme/revision features.

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flashforge Ready Ready Preview Oct 9, 2026 7:29am UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T07:33:02.793633Z c791220 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@stupidgiraffe
stupidgiraffe merged commit 6156d3d into main Oct 9, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c791220ad9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx
backText: card.backText,
})
setImageSearchQuery(intent.query)
setImageSearchResultsQuery(intent.query)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the originating query for saved candidates

When this dialog opens stored review candidates, this assigns a newly reconstructed default query rather than the query that produced those candidates. The image agent normally searches with styles such as clear photo isolated subject (and can use custom or revision queries), while buildImageSearchIntent here typically reconstructs clear simple illustration; selecting a stored candidate then re-runs that different query, so the API cannot find the candidate URL and returns image_selection_expired. Persist and reuse the candidates' originating query (or a server-issued selection token) so the existing “Review image options” flow remains selectable.

Useful? React with 👍 / 👎.

Comment thread api/image-search.js
})
}
try {
const dataUrl = await embedImage(selected.url)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate redirect destinations before embedding images

A fresh provider result is still an untrusted external URL, so it does not establish an SSRF boundary: an indexed attacker-controlled image URL can redirect to a loopback, private-network, or cloud-metadata address. embedImage explicitly uses redirect: 'follow' and performs no hostname or resolved-IP validation, allowing this new selected-image route (and its thumbnail fallback) to make the server follow that redirect. Reject private/reserved destinations after DNS resolution and validate every redirect hop before downloading.

Useful? React with 👍 / 👎.

This branch was successfully deployed

1 active deployment
Preview — c791220a Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant