Skip to content

Backfill recipe names when importing shared QR cards - #61

Merged
gosku merged 6 commits into
mainfrom
feature/backfill-recipe-name-on-card-import
Jul 13, 2026
Merged

Backfill recipe names when importing shared QR cards#61
gosku merged 6 commits into
mainfrom
feature/backfill-recipe-name-on-card-import

Conversation

@gosku

@gosku gosku commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Previous behaviour

A card is matched against the library by its settings. If a recipe with those
settings is already there, the import reuses it instead of adding a second copy.
Reusing it never touched its name: a name is only ever set at the moment a
recipe is first created.

The problem

Sharing a named recipe with a library that already has that recipe
transferred nothing. The name on the card was silently dropped.

What this PR does

A recipe that is matched but has no name now takes the name from the card.
A name chosen locally is never overwritten, and the description is untouched
(cards don't carry one).

gosku and others added 6 commits July 13, 2026 15:09
The QR payload checks only that a field has the right type. Value rules
live in the FujifilmRecipeData validators, which raise plain ValueErrors
when the query builds the dataclass: an over-long or non-ASCII name, or a
sensor name this deployment does not know.

The card import catches only QRCodeNotFoundError and
InvalidQRRecipePayloadError, so one such card aborted the whole upload
rather than being recorded as a single failed file.

Translate those ValueErrors into InvalidQRRecipePayloadError with a new
"invalid_field_value" reason, so the offending card lands in the failed
list and the rest of the batch imports.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
set_recipe_name published RECIPE_IMAGE_UPDATED, which describes a
different state change: nothing about a recipe image changes when a
recipe is named. The constant stays, because process_image publishes it
correctly when it updates an existing image row.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A recipe shared as a QR card is matched against the library by its
settings, so importing one usually takes the get path, where name and
description are only create-time defaults. The name on the card was
therefore dropped, which is the whole point of sharing a named recipe.

Name an existing recipe from the incoming data, but only when it has no
name of its own: a name chosen locally is never overwritten, and the
description is never touched (a card does not carry one).

get_or_create_recipe_from_data keeps its contract, so the EXIF and manual
creation callers are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The operation may now name the recipe a card matches, so a get_or_create
name would promise less than it does. Its one caller keeps discarding the
outcome for now; the use case starts reporting it next.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A bulk import of shared cards mostly matches recipes the library already
has, so "100 recipes imported" says nothing about what actually happened.

Split the successes into the recipes the import created and the ones it
completed by naming them. The EXIF importer shares the result type and
cannot tell the two apart, so both fields default to empty there and
imported stays the whole story.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Importing a batch of shared cards mostly matches recipes the library
already has, so "100 recipes imported successfully" left you unable to
tell whether anything landed. Report how many recipes the import created
and how many it completed by naming them.

The counts, not the recipes, go into the template context, and the line
is omitted when there is nothing to report -- including for the EXIF
importer, which shares this partial and cannot tell the two apart.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gosku
gosku merged commit c8d0f78 into main Jul 13, 2026
4 checks passed
@gosku
gosku deleted the feature/backfill-recipe-name-on-card-import branch July 13, 2026 09:56
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