cooklang / cooklang/federation

GitHub indexer never refreshes recipes.content when a .cook file changes

Open
#12 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
17
Forks
4
Avg merge
5m
Merged PRs (30d)
1

Description

## Problem

When a `.cook` file changes upstream, `GitHubIndexer::index_recipe` (`src/github/indexer.rs`) updates **only the file SHA**. The `recipes.content` column is never refreshed, so the stored recipe body silently drifts from what's actually in the repository.

The update arm still carries a comment admitting it:

```rust
// Update recipe content (use existing update function if available)
// For now, we'll keep the existing recipe and just update the github_recipe SHA
db::github::update_github_recipe_sha(&self.pool, existing.id, file_sha).await?;
```

## Why it matters more than it looks

The code *after* that branch re-extracts **ingredients, cookware, tags** — and now **locale** (added in #11) — from the **newly downloaded** content. So a changed recipe ends up with:

- derived data (ingredients / tags / locale) computed from the **new** file, and
- `recipes.content` still holding the **old** file.

The row asserts a locale and an ingredient list describing text the database doesn't store. The recipe detail page renders from `recipes.content`, so users see the stale body alongside fresh derived metadata.

Note the early return upstream means this only fires when the SHA genuinely changed — i.e. exactly when the content *did* change:

```rust
if existing.file_sha == file_sha {
return Ok(existing.recipe_id); // unchanged file, nothing to do
}
```

## Suggested fix

On the update path, refresh the recipe row from the new content — title, summary, image, `content`, and `content_hash` — the way the feed crawler already does via `db::recipes::update_recipe_with_content` (which recomputes locale as part of the same call).

## Context

Found while implementing recipe locale detection (#11). Deliberately left out of scope there: it's a pre-existing bug and bigger than locale.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/github/indexer.rs at GitHubIndexer::index_recipe and compare the update path with the feed crawler's use of db::recipes::update_recipe_with_content. Ensure a changed .cook file refreshes title, summary, image, content, and content_hash while keeping derived data aligned with the new content.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.