Fix product slug resolution: fall back to g.post_slug
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 55s

App-level url_value_preprocessor pops slug into g.post_slug before
the blueprint preprocessor runs, leaving values empty. Fall back to
g.post_slug so resolve_product and cart route get the slug.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-24 09:57:42 +00:00
parent 3c9ff1210a
commit f53d2841e9

View File

@@ -25,7 +25,9 @@ def register():
bp = Blueprint("product", __name__, url_prefix="/product/<slug>")
@bp.url_value_preprocessor
def pull_blog(endpoint, values):
g.product_slug = values.get("slug")
# App-level preprocessor pops "slug" into g.post_slug before this runs,
# so values.get("slug") is None. Fall back to g.post_slug.
g.product_slug = values.get("slug") or getattr(g, "post_slug", None)
# ─────────────────────────────────────────────────────────────
# BEFORE REQUEST: Slug or numeric ID resolver