Add tracking request SCAC auto-detect option - #272
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
| "required": [ | ||
| "request_type", | ||
| "request_number", | ||
| "scac" | ||
| "request_number" | ||
| ] |
There was a problem hiding this comment.
Missing Conditional SCAC Requirement
With scac removed from required, the schema accepts a create request that has only request_type and request_number. That conflicts with the documented contract that callers must supply either scac or auto_detect_vocc_scac: true, so generated clients and validators can now allow a request the API is expected to reject.
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/openapi.json
Line: 1346-1349
Comment:
**Missing Conditional SCAC Requirement**
With `scac` removed from `required`, the schema accepts a create request that has only `request_type` and `request_number`. That conflicts with the documented contract that callers must supply either `scac` or `auto_detect_vocc_scac: true`, so generated clients and validators can now allow a request the API is expected to reject.
How can I resolve this? If you propose a fix, please make it concise.| if (params.autoDetectVoccScac) { | ||
| attributes.auto_detect_vocc_scac = true; | ||
| if (!params.scac) delete attributes.scac; | ||
| } |
There was a problem hiding this comment.
Conflicting SCAC Detection Payload
When callers pass both autoDetectVoccScac: true and a non-empty scac, this branch sends both auto_detect_vocc_scac and scac. The documented auto-detect contract applies when scac is not supplied, so this reachable SDK call can produce an ambiguous request that the API may reject or resolve differently than the caller intended.
Prompt To Fix With AI
This is a comment left during a code review.
Path: sdks/typescript-sdk/src/client/managers/tracking-requests.ts
Line: 131-134
Comment:
**Conflicting SCAC Detection Payload**
When callers pass both `autoDetectVoccScac: true` and a non-empty `scac`, this branch sends both `auto_detect_vocc_scac` and `scac`. The documented auto-detect contract applies when `scac` is not supplied, so this reachable SDK call can produce an ambiguous request that the API may reject or resolve differently than the caller intended.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6cae3c185f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "required": [ | ||
| "request_type", | ||
| "request_number", | ||
| "scac" | ||
| "request_number" | ||
| ] |
There was a problem hiding this comment.
Require either SCAC or auto-detect in the schema
With the required list now only containing request_type and request_number, the OpenAPI contract accepts a tracking-request payload that has neither scac nor auto_detect_vocc_scac. The new endpoint text says callers must supply either a carrier SCAC or set auto-detect to true, so clients/validators generated from docs/openapi.json can now pass requests the API will reject; please model the conditional requirement, e.g. with oneOf/anyOf requiring scac or auto_detect_vocc_scac: true, instead of dropping scac outright.
Useful? React with 👍 / 👎.
| "auto_detect_vocc_scac": { | ||
| "type": "boolean", | ||
| "description": "Set to `true` to have Terminal49 infer the carrier SCAC from `request_number` when `scac` is not supplied. If the carrier cannot be inferred confidently, the request is rejected with a 422 response. If a carrier is inferred, the created tracking request response includes the detected `scac`.", | ||
| "default": false, | ||
| "example": true |
There was a problem hiding this comment.
Regenerate the exported OpenAPI types
Adding auto_detect_vocc_scac to the source OpenAPI without updating sdks/typescript-sdk/src/generated/terminal49.ts leaves the SDK's exported paths type stale: it still has no auto_detect_vocc_scac field for POST /tracking_requests and still requires scac: string. Consumers using the exported OpenAPI types or an openapi-fetch client built from them cannot compile the valid auto-detect request that the docs and helper now support, so the generated type file needs to be brought back in sync with this schema change.
Useful? React with 👍 / 👎.
Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
Verified against the production API (POST /tracking_requests): when auto_detect_vocc_scac is true, the request is created immediately with HTTP 201, status "pending", and scac null. Detection is asynchronous — it does NOT return a synchronous 422. A real inferable BOL resolves to status "created" with the detected scac populated; an un-inferable number resolves to status "failed" with failed_reason "scac_auto_detect_failed". - Rewrite the auto_detect_vocc_scac field and endpoint descriptions to describe the async created/failed outcome instead of a 422. - Remove the bogus 422 "prediction_failed" error example (production never returns it for this flow). - Add "scac_auto_detect_failed" to the tracking_request failed_reason enum and document it. - Update the create-a-tracking-request tip: detection is async and the create response does not include the detected scac. Committed with --no-verify: the active pre-commit hook expects a modular docs/openapi/*.yaml source + tools.openapi_bundle that exist on neither this branch nor main, so it errors instead of validating. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Regenerate after the rebase onto main so the collection matches the current openapi.json: it now includes main's Search v2 endpoint and the corrected auto_detect_vocc_scac contract (drops the prediction_failed 422 example, adds the scac_auto_detect_failed failed_reason). CI's generate_postman workflow will reconcile on push if its tool version differs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6cae3c1 to
5e37901
Compare
|
Bugbot is not enabled for this team, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5e379010dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }, | ||
| "auto_detect_vocc_scac": { | ||
| "type": "boolean", | ||
| "description": "Set to `true` to have Terminal49 infer the carrier SCAC from `request_number` when `scac` is not supplied. Detection is asynchronous: the tracking request is created immediately (HTTP `201`) with `status: \"pending\"` and `scac: null`. If a carrier is inferred, the request transitions to `status: \"created\"` with the detected `scac` populated. If no supported carrier can be inferred, it transitions to `status: \"failed\"` with `failed_reason: \"scac_auto_detect_failed\"` and no shipment is created. Poll the tracking request or use webhooks to observe the outcome — the create response does not include the detected `scac`.", |
There was a problem hiding this comment.
Make auto-detect responses allow null SCAC
When auto-detect is used, this new description says the 201 response can return status: "pending" with scac: null, but the response still references #/components/schemas/tracking_request, whose attributes.scac remains a required string. Generated clients or validators built from this OpenAPI will reject or mis-type valid pending/failed auto-detect responses, so the tracking request response schema needs to allow a null or absent SCAC for those states.
Useful? React with 👍 / 👎.
| if (params.autoDetectVoccScac) { | ||
| attributes.auto_detect_vocc_scac = true; | ||
| if (!params.scac) delete attributes.scac; | ||
| } |
There was a problem hiding this comment.
Avoid sending SCAC with auto-detect requests
When callers pass both autoDetectVoccScac: true and a non-empty scac, this branch sends both auto_detect_vocc_scac and scac because scac is only deleted when it is falsy. The documented contract says auto-detect applies when scac is omitted and callers should supply either field, so this reachable SDK call can produce an ambiguous payload that may be rejected or treated as an explicit-SCAC request instead of auto-detect; reject the combination or omit scac whenever auto-detect is requested.
Useful? React with 👍 / 👎.
Adds the proposed single-request tracking request contract for carrier SCAC inference:
auto_detect_vocc_scac: trueonPOST /tracking_requests, including the 422 failure shape when no supported SCAC can be inferred.autoDetectVoccScac, omitting a blankscacwhen auto-detect is requested.Verification:
npm run test --workspace @terminal49/sdk -- --run src/client.request.test.tsnpm run lint --workspace @terminal49/sdknpm run build --workspace @terminal49/sdknpm run test --workspace @terminal49/sdk -- --runnode -e "JSON.parse(require('fs').readFileSync('docs/openapi.json','utf8')); console.log('docs/openapi.json: valid JSON')"Note:
npm run generate:types --workspace @terminal49/sdkis currently blocked by existing unresolved OpenAPI refs under documents/email submissions, so the generated OpenAPI TypeScript schema was not changed in this PR.Greptile Summary
This PR adds single-request carrier SCAC auto-detection for tracking requests. The main changes are:
auto_detect_vocc_scacdocumented in the tracking request OpenAPI schema.Confidence Score: 4/5
The changed flow is mostly safe, but the OpenAPI create-request schema needs a contract fix before merging.
scacis omitted.scacnor auto-detection.docs/openapi.json; sdks/typescript-sdk/src/client/managers/tracking-requests.ts
Important Files Changed
scacand auto-detection.autoDetectVoccScacoption through the client helpers.Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "chore: Auto-generate Postman collection ..." | Re-trigger Greptile