Repository navigation
fix(server): name recipes relative to the collection in GET /api/recipes - #639
Merged
Merged
Conversation
Since be92001 the recipe tree has been `cooklang_find`'s, serialised as is, so every node's `path` and every recipe's `source.path` was the file's absolute path on the server. That read is open to anyone, a visitor who is not signed in included, and it is on the --recipes-only allowlist: it told them where the collection sits and, usually, the account the server runs as. Both are now relative to the recipe directory (`Breakfast/Pancakes.cook`), the root's being "". They are what `GET /api/recipes/{*path}` takes. The recipe picker, the one client in the repo, already reduced the absolute paths to these, and works unchanged. Closes cooklang#638 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #638.
GET /api/recipesanswered withcooklang_find's tree as is, so every node'spathand every recipe'ssource.pathwas the file's absolute path on the server (/home/<user>/recipes/Breakfast/Pancakes.cook). This started with be92001; before it, the endpoint returned relative names.The read is open to everyone: with sign-in on, visitors who have not signed in get it. It is also on the
--recipes-onlyallowlist, so guests limited to recipes get it too. It told them where the collection sits on the server and, usually, which account runs it.Change
all_recipesrewrites the serialised tree (relative_tree_paths, next to the existingnormalize_tree_tags).pathandrecipe.source.pathis now relative to the recipe directory:Breakfast/Pancakes.cook, with the root's being"". That is exactly whatGET /api/recipes/{*path}takes.cooklang_finddoes not produce, would come back as its bare file name rather than leak.static/js/src/picker.js), the only client in the repo, already reduced the absolute paths to these relative ones, and works unchanged; only its comment changed.docs/api.md//api-docsnow document relative paths.Visible change: an outside client that relied on absolute paths would now get paths relative to the collection.
Tests
source.path) and the outside-the-directory fallback.tests/recipe_tree_paths_test.rsbootscook serveron a temp collection (viawith_isolated_config). It checks that the raw answer never contains the temp directory, that the paths are exactly the expected relative ones (root recipe, recipe in a folder, a menu), and that each opens its recipe throughGET /api/recipes/{path}.cargo fmt,cargo clippy --workspace --all-targets --all-features -- -D warningsandcargo test(1103 passed) are clean.static-file-search(needs acookbinary in the container), one parallel shopping-list race, and the known-flakyrecipe-scaling › should send the scale…. That race and the flaky test pass when run serially, along withmenu-editor(which uses the picker): 64/64.Related: #637 (the Preferences page shows absolute paths too), and #631, which keeps them out of the new aisles API.
🤖 Generated with Claude Code