Add debug logging to recipe upload and get
To help diagnose why recipes are not found after upload. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,10 +33,15 @@ class RecipeService:
|
|||||||
async def get_recipe(self, recipe_id: str) -> Optional[Recipe]:
|
async def get_recipe(self, recipe_id: str) -> Optional[Recipe]:
|
||||||
"""Get a recipe by ID (content hash)."""
|
"""Get a recipe by ID (content hash)."""
|
||||||
import yaml
|
import yaml
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Get from cache (content-addressed storage)
|
# Get from cache (content-addressed storage)
|
||||||
|
logger.info(f"get_recipe: Looking up recipe_id={recipe_id[:16]}...")
|
||||||
path = self.cache.get_by_cid(recipe_id)
|
path = self.cache.get_by_cid(recipe_id)
|
||||||
|
logger.info(f"get_recipe: cache.get_by_cid returned path={path}")
|
||||||
if not path or not path.exists():
|
if not path or not path.exists():
|
||||||
|
logger.warning(f"get_recipe: Recipe {recipe_id[:16]}... not found in cache")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
@@ -160,14 +165,18 @@ class RecipeService:
|
|||||||
return None, f"Compile error: {e}"
|
return None, f"Compile error: {e}"
|
||||||
|
|
||||||
# Write to temp file for caching
|
# Write to temp file for caching
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
try:
|
try:
|
||||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".sexp", mode="w") as tmp:
|
with tempfile.NamedTemporaryFile(delete=False, suffix=".sexp", mode="w") as tmp:
|
||||||
tmp.write(content)
|
tmp.write(content)
|
||||||
tmp_path = Path(tmp.name)
|
tmp_path = Path(tmp.name)
|
||||||
|
|
||||||
# Store in cache (content-addressed, auto-pins to IPFS)
|
# Store in cache (content-addressed, auto-pins to IPFS)
|
||||||
|
logger.info(f"upload_recipe: Storing recipe in cache from {tmp_path}")
|
||||||
cached, ipfs_cid = self.cache.put(tmp_path, node_type="recipe", move=True)
|
cached, ipfs_cid = self.cache.put(tmp_path, node_type="recipe", move=True)
|
||||||
recipe_id = ipfs_cid or cached.cid # Prefer IPFS CID
|
recipe_id = ipfs_cid or cached.cid # Prefer IPFS CID
|
||||||
|
logger.info(f"upload_recipe: Stored recipe, cached.cid={cached.cid[:16]}..., ipfs_cid={ipfs_cid[:16] if ipfs_cid else None}, recipe_id={recipe_id[:16]}...")
|
||||||
|
|
||||||
# Track ownership in item_types and assign friendly name
|
# Track ownership in item_types and assign friendly name
|
||||||
if uploader:
|
if uploader:
|
||||||
|
|||||||
Reference in New Issue
Block a user