DEV Community

Leo Qi
Leo Qi

Posted on

Route Quote and Parts Forms Without Silently Dropping Requests

A product page can offer two distinct buttons while its server still treats every submission as a generic lead. The failure mode is subtle: the browser displays a success message, sales sees a parts request days later, and nobody checks whether the support route was configured.

Route on stable values

Send a stable product ID and a small intent value such as quote or parts. On the server, resolve the product within the site's shop or tenant context. Never accept a destination address or tenant ID from an untrusted form field. Use server-side configuration to select a queue. If that configuration is missing, return an actionable error rather than silently sending to sales.

ALLOWED_INTENTS = frozenset({"quote", "parts"})

def queue_for(shop, product_id, intent, products, routes):
    # shop comes from trusted site context, not the submitted form.
    if intent not in ALLOWED_INTENTS:
        raise ValueError("unknown request type")
    if (shop, product_id) not in products:
        raise LookupError("product not found on this site")
    queue = routes.get((shop, intent))
    if not queue:
        raise RuntimeError("request type is not configured for this site")
    return queue

products = {("shop-a", "pump-42")}
routes = {("shop-a", "parts"): "service-a"}
assert queue_for("shop-a", "pump-42", "parts", products, routes) == "service-a"
try:
    queue_for("shop-a", "pump-42", "quote", products, routes)
except RuntimeError:
    pass
else:
    raise AssertionError("an unconfigured route must not succeed")
Enter fullscreen mode Exit fullscreen mode

Keep route selection separate from receipt creation. Only show the visitor a reference ID once the request has been durably stored for the assigned queue. A queue outage and a missing routing rule are both operational errors, but they mean different things to the team investigating.

Before release, test the happy path, the wrong-shop product ID, and an intentionally disabled route. Also inspect the product shown to the receiving team: a queue name alone doesn’t tell a technician which machine the visitor needs help with.

If a visitor retries after a network timeout, reuse the same submission key for that attempt. Otherwise, two saved requests can create two tickets even when the browser only showed one confirmation.

Top comments (0)