Skip to content

fix poem image - #1006

Closed
Tech-lo wants to merge 13 commits into
developfrom
poem-image
Closed

Tech-lo wants to merge 13 commits into
developfrom
poem-image

Conversation

@Tech-lo

@Tech-lo Tech-lo commented Sep 10, 2026

Copy link
Copy Markdown
Member

@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

The PR is not yet safe to merge because explicit poem IDs can bind previews to the wrong shared resource, and transient fallback images remain cached after recovery.

Findings

  1. P1 Poem ID overrides shared resource ▶
  2. P1 Fallback image remains cached ▶
Fix with agent prompt
### Issue 1
pecha_api/share/share_service.py:181-182
When a share request supplies a `poem_id` that differs from the poem in its URL or accompanies a segment/text URL, this branch preserves that ID, skips segment/text image generation, and builds the preview from the supplied poem, causing crawlers to display an image that does not represent the shared resource.

### Issue 2
pecha_api/share/share_service.py:undefined-124
When a poem image is temporarily unavailable, the neutral fallback receives the same 24-hour public cache policy as a successful image, causing caches and crawlers to keep showing the fallback after the poem image becomes available again.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

  • Extracts poem IDs from shared URLs and resolves published poem metadata.
  • Handles GET and HEAD image requests with fixed-length responses.
  • Moves synchronous poem lookups into worker threads.
  • Adds coverage for image conversion, fallback behavior, routing, and metadata generation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[POST share request] --> B{poem_id supplied?}
  B -- No --> C[Extract poem ID from URL]
  B -- Yes --> D[Keep supplied poem ID]
  C --> E{Poem ID present?}
  D --> E
  E -- No --> F[Generate segment or text image]
  E -- Yes --> G[Resolve poem title]
  G --> H[Create poem image URL]
  H --> I[GET or HEAD share/image]
  I --> J{Published image available and decodable?}
  J -- Yes --> K[Normalize to 1200x630 JPEG]
  J -- No --> L[Generate neutral in-memory PNG]
Loading

Reviews (14) · Last reviewed commit: "image size fix"

Comment thread pecha_api/share/share_service.py Outdated
Comment thread pecha_api/share/share_service.py Outdated
Comment thread pecha_api/share/share_service.py
Comment thread pecha_api/share/share_service.py Outdated
Comment thread pecha_api/share/share_service.py Outdated
Comment thread pecha_api/share/share_service.py Outdated
Comment thread pecha_api/share/share_service.py Outdated
Comment thread pecha_api/share/share_service.py Outdated
@tenkus47
tenkus47 self-requested a review September 10, 2026 10:01
Comment thread pecha_api/share/share_service.py Outdated
return Response(
content=image_bytes,
media_type=media_type,
headers={"Cache-Control": "public, max-age=86400"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Fallback image remains cached

When a poem image is temporarily unavailable, the neutral fallback receives the same 24-hour public cache policy as a successful image, causing caches and crawlers to keep showing the fallback after the poem image becomes available again.

Prompt To Fix With AI
This is a comment left during a code review.
Path: pecha_api/share/share_service.py
Line: 108

Comment:
**Fallback image remains cached**

When a poem image is temporarily unavailable, the neutral fallback receives the same 24-hour public cache policy as a successful image, causing caches and crawlers to keep showing the fallback after the poem image becomes available again.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +181 to +182
if share_request.poem_id is None:
share_request.poem_id = _extract_poem_id_from_url_(share_request.url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Poem ID overrides shared resource

When a share request supplies a poem_id that differs from the poem in its URL or accompanies a segment/text URL, this branch preserves that ID, skips segment/text image generation, and builds the preview from the supplied poem, causing crawlers to display an image that does not represent the shared resource.

Prompt To Fix With AI
This is a comment left during a code review.
Path: pecha_api/share/share_service.py
Line: 181-182

Comment:
**Poem ID overrides shared resource**

When a share request supplies a `poem_id` that differs from the poem in its URL or accompanies a segment/text URL, this branch preserves that ID, skips segment/text image generation, and builds the preview from the supplied poem, causing crawlers to display an image that does not represent the shared resource.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@sonarqubecloud

Copy link
Copy Markdown

@tenkus47 tenkus47 closed this Sep 14, 2026
@tenkus47
tenkus47 deleted the poem-image branch September 17, 2026 04:28
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.

2 participants