fix: 404 unresolvable deal_id and quote_id on order create - #71
Open
aleksUIX wants to merge 1 commit into
Open
Conversation
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.
Summary
Fixes #68 and #70.
POST /api/v1/orderswrotedeal_idandquote_idstraight through. An unknowndeal_idpersisted as a draft; a change request against that order then inherited the reference and reachedpending_approvalat material severity withvalidation_errorsempty. An unknownquote_iddid 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/dealsreturns404 quote_not_foundfor the same missing quote.GET /api/v1/deals/{id}returns404 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, afterget_storage():deal_id→storage.get_deal; miss →404 deal_not_found(same detail asget_deal)quote_id→storage.get_quote; miss →404 quote_not_found(same detail asbook_deal/get_quote)For orders already stored with a phantom
deal_id(the #68 change-request path),create_change_requestdoes the same lookup after the order exists and before classifying severity or writing a CR. Empty /Noneis left alone so this does not collide with #65 (deal_id_requiredfor dealless orders).Out of scope (deliberate)
quote_idbelongs to the given deal (POST /api/v1/orders accepts and persists an unresolvable quote_id for a valid deal #70 explicitly untested).None→""write-side normalization, nodeal_id_required400. Those PRs compose: fix: reject change requests for dealless orders #65 rejects missing ids, this rejects present-but-unknown ids.gam_reporting_serviceconsumption oforder["deal_id"]). Once create refuses unknown ids, new orders cannot feed that path a phantom reference.Test plan
test_create_order_returns_draft)deal_id→ 404deal_not_found, no order row (POST /api/v1/orders accepts an unresolvable deal_id, and the reference propagates into a material change request #68 curl)quote_id→ 404quote_not_found, no order row (POST /api/v1/orders accepts and persists an unresolvable quote_id for a valid deal #70, including with a known deal)deal_idis not in storage → 404deal_not_found, no CR record, neverpending_approvalwith emptyvalidation_errorsuv run --locked ruff check src/andruff format --checkcleanCloses #68
Closes #70