Skip to content

fix(server): recognize duration and time required as time aliases#342

Merged
dubadub merged 1 commit into
mainfrom
fix/time-metadata-aliases
May 15, 2026
Merged

fix(server): recognize duration and time required as time aliases#342
dubadub merged 1 commit into
mainfrom
fix/time-metadata-aliases

Conversation

@dubadub
Copy link
Copy Markdown
Member

@dubadub dubadub commented May 15, 2026

Summary

  • The Cooklang spec defines time, duration, and time required as aliases for the canonical time metadata key (see cooklang-rs/src/metadata.rs:87), but the server's recipe and menu pages only looked up the literal time key, so recipes using either alias rendered no time pill.
  • Add fallback lookups for duration and time required in both recipe_page and the menu handler, mirroring the existing alias pattern used for prep time / cook time.

Test plan

  • cargo fmt, cargo clippy, cargo test clean
  • Manually verified against cook server with three recipes (time:, duration:, time required:) — all three render the same ⏱️ <value> pill, no duplication under custom metadata

Closes #320

The Cooklang spec lists `time`, `duration`, and `time required` as aliases
for the canonical `time` key, but the server only looked up `time`, so the
other two were silently dropped from the recipe page.

Closes #320
@claude
Copy link
Copy Markdown

claude Bot commented May 15, 2026

Code Review — PR #342

Overview

Adds fallback lookups for duration and time required metadata aliases in recipe_page and menu_page_handler, matching the Cooklang spec's canonical alias definitions.

Code Quality

  • Clean, minimal fix — exactly the right amount of change.
  • Correctly mirrors the established .or_else() chain pattern already used for prep_time / cook_time aliases on the lines immediately below.
  • Applied consistently in both locations that construct RecipeMetadata.

Potential Issues

  • Missing location: There may be other RecipeMetadata construction sites. Worth a quick sanity-check to confirm these are the only two:
    grep -n 'RecipeMetadata {' src/server/ui.rs
    If there are others, they'll need the same fallback chain.
  • Alias priority: The lookup order (timedurationtime required) is reasonable and matches the cooklang-rs canonical ordering. No change needed — just worth noting it's intentional.

Verdict

Looks good. The fix is correct, consistent with the existing code style, and closes the reported issue cleanly.

@dubadub dubadub merged commit d685eaf into main May 15, 2026
6 checks passed
@dubadub dubadub deleted the fix/time-metadata-aliases branch May 15, 2026 18:06
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.

[server] time required or duration not recognized as aliases of time

1 participant