Skip to content

fix: 404 unresolvable deal_id and quote_id on order create - #71

Open
aleksUIX wants to merge 1 commit into
IABTechLab:mainfrom
aleksUIX:fix/orders-resolve-parent-ids
Open

fix: 404 unresolvable deal_id and quote_id on order create#71
aleksUIX wants to merge 1 commit into
IABTechLab:mainfrom
aleksUIX:fix/orders-resolve-parent-ids

Conversation

@aleksUIX

Copy link
Copy Markdown
Contributor

Summary

Fixes #68 and #70. POST /api/v1/orders wrote deal_id and quote_id straight through. An unknown deal_id persisted as a draft; a change request against that order then inherited the reference and reached pending_approval at material severity with validation_errors empty. An unknown quote_id did the same on a valid deal, so the order's quote disagreed with the deal's.

The adjacent hop already resolves its parent: POST /api/v1/deals returns 404 quote_not_found for the same missing quote. GET /api/v1/deals/{id} returns 404 deal_not_found. Orders now match that contract.

Omitted / null ids stay allowed. An order can still be drafted before commercial terms exist. A provided id must already be in storage.

Fix

In create_order, after get_storage():

  • non-empty deal_idstorage.get_deal; miss → 404 deal_not_found (same detail as get_deal)
  • non-empty quote_idstorage.get_quote; miss → 404 quote_not_found (same detail as book_deal / get_quote)
  • nothing is persisted on either miss

For orders already stored with a phantom deal_id (the #68 change-request path), create_change_request does the same lookup after the order exists and before classifying severity or writing a CR. Empty / None is left alone so this does not collide with #65 (deal_id_required for dealless orders).

if deal_id:
    deal = await storage.get_deal(deal_id)
    if not deal:
        raise HTTPException(
            status_code=404,
            detail={"error": "deal_not_found", "message": f"Deal '{deal_id}' not found."},
        )
if quote_id:
    quote = await storage.get_quote(quote_id)
    if not quote:
        raise HTTPException(
            status_code=404,
            detail={"error": "quote_not_found", "message": f"Quote '{quote_id}' not found."},
        )

Out of scope (deliberate)

Test plan

Closes #68
Closes #70

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant