Skip to content

fix(diagnostics): classify transport failures and describe stock refusals - #1557

Merged
itsbkm merged 2 commits into
mainfrom
fix/support-findings-1551-b
Nov 13, 2026
Merged

itsbkm merged 2 commits into
mainfrom
fix/support-findings-1551-b

Conversation

@itsbkm

@itsbkm itsbkm commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Related work

Issue / Discussion: #1551 (fix order items 2 and 3)

Summary

  • Transport failures: the POS page and payment modal now share one classifier (frontend/src/lib/transport-failure.ts). It adds aborted and connection_reset, and falls back to unknown instead of unreachable.
  • Stock refusals: order.stock_insufficient now carries stock_scope (product, variant, add-on) and stock_shortfall (out_of_stock, partial) as facts. They are returned in the 400 response, captured to diagnostics, and relayed in the support report by the POS page. The client parser accepts only those two approved values.
  • Item 2 deviates from the issue text on purpose: facts carry no item id and no requested/available amounts. Facts feed the cloud aggregate key and telemetry, so ids would leave the device and exact amounts would make nearly every refusal a unique row. Approved before building.
  • fix(pos): harden support logs & print errors #1541 check: already covered by tests/support-ticket.test.ts (stock rejection uses the validation variant) and frontend/e2e/diagnostics-checkout-recovery.spec.ts.
  • API docs updated.

Scope

Add-on pre-check refusals (addon_item_validation) and the append route are unchanged.

Verification

Commands run: npm run lint, npm run build, npm run build:frontend, npm run i18n:check, npm run docs:check, git diff --check, and the test:transport-failure-class (new), test:diagnostics-event, test:issue-788-order-attempt-storage, test:support-ticket, test:inventory-ledger, test:diagnostic-signature, test:diagnostics-outbox-bounds, test:diagnostic-wire-producer, test:product-variants-api, test:addon-inventory-orders, test:multi-counter-ordering, test:telemetry-leakage-prevention, test:script-coverage suites.
Results: all pass; lint shows only pre-existing warnings. Full npm test and the e2e suite were not run.

Compatibility & data safety

  • Database/data impact: None
  • Migration: None
  • User-visible behavior: None visible; diagnostics and support reports carry more detail
  • Offline/network impact: None. If the cloud receiver validates failure_class values strictly, aborted and connection_reset may be dropped until it is updated.

Cross-cutting surfaces

Surface Status
UI not affected (support report payload only)
API affected (facts on stock refusal responses)
Persistence not affected
Upgrade path not affected

Developer documentation

  • Existing developer documentation updated: docs/reference/api.md (order failure facts)

Contributor checklist

  • This is a small isolated fix/doc update OR follows an approved issue/direction.
  • Unrelated cleanups, refactors, and dependency changes were kept out of this PR.
  • Tests were added or updated for any behavior changes.
  • Verification commands were run and documented above.
  • Customer data and upgrade safety were preserved (if touching database/storage).
  • Documentation or translations were updated where relevant.
  • I understand and can explain all submitted changes.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Stock-related order refusals now include safe details indicating whether the affected inventory is for a product, variant, or add-on, and whether it is unavailable or partially available.
    • Network and payment failures are classified consistently, with relevant details available in support reports.
  • Documentation
    • Updated the Orders API reference to describe the stock-refusal details included in order-creation errors.

itsbkm and others added 2 commits November 14, 2026 03:19
…o unreachable

Share one classifier between the POS page and the payment modal. It now
separates aborted requests and connection resets from true network failures,
and falls back to unknown instead of unreachable.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Order-creation stock refusals now carry stock_scope (product, variant or
add-on) and stock_shortfall (out of stock or partial) as diagnostic facts,
returned in the response and relayed in support reports. Facts carry no item
identity or quantities.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Order stock-refusal responses now include bounded scope and shortfall facts. Frontend order-failure handling validates and reports those facts. POS and support code use a shared transport-failure classifier and class list.

Changes

Operation failure diagnostics

Layer / File(s) Summary
Define and capture stock-refusal facts
main/lib/operation-failure.ts, main/services/inventory.ts, tests/diagnostics-event.test.ts
The failure registry defines allowed stock scopes and shortfalls. Inventory errors attach refusal details based on the relevant stock pool. Tests check the reported facts for empty and partly available stock.
Return and validate stock-refusal facts
main/routes/orders.ts, frontend/src/lib/order-attempt.ts, frontend/src/app/(dashboard)/pos/page.tsx, frontend/src/components/support/SupportTicketForm.tsx, docs/reference/api.md, tests/issue-788-order-attempt-storage.test.ts
Order routes include refusal facts in structured responses. Frontend classification accepts only the permitted fields and values for order-creation stock validation. POS reporting, support types, API documentation, and tests cover the facts.
Share transport-failure classification
frontend/src/lib/transport-failure.ts, frontend/src/lib/api.ts, frontend/src/app/(dashboard)/pos/page.tsx, frontend/src/components/pos/PaymentModal.tsx, frontend/src/app/(dashboard)/support/page.tsx, tests/transport-failure-class.test.ts, package.json
The frontend defines transport-failure classes and a classifier. POS and support code use the shared classes. Tests cover classification and serialization, and the test script runs the new test.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: Minimal · up to 2203d

The change standardizes transport-failure classification and adds bounded stock-refusal facts to order failures. No concrete regression was found. Confirm that the cloud diagnostics receiver accepts the two new failure classes when rolling out.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two changes in the PR: transport failure classification and stock refusal facts. The raw summary shows both are implemented in the diff (transport-failure.ts, PaymentModal, POS pag…
Description check Passed The description follows the repository template. It includes Related work, Summary, Scope, Verification with commands and results, Compatibility and data safety, Cross-cutting surfaces, Developer docu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two changes in the PR: transport failure classification and stock refusal facts. The raw summary shows both are implemented in the diff (transport-failure.ts, PaymentModal, POS page, order-attempt, inventory.ts). The title is conventional and specific, and it does not mention the API docs or tests, which is acceptable.

Full details: Description check

Explanation

The description follows the repository template. It includes Related work, Summary, Scope, Verification with commands and results, Compatibility and data safety, Cross-cutting surfaces, Developer documentation, and the contributor checklist. The Screenshots section is omitted, which is acceptable because the PR has no UI change. The Summary explains the design choices, and the Scope section states what is unchanged. Two items are weaker: the Cross-cutting surfaces table omits several listed rows (CSV, Web print, Thermal print, LAN/server app, RTL, Dark mode, Timezone, Permissions), and the Verification section lists commands but does not give a per-command result. The template's 'delete rows that don't apply' guidance makes the omission of unaffected rows acceptable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bfde7b7 and 2203d76.

Files selected for processing: 15

  • docs/reference/api.md
  • frontend/src/app/(dashboard)/pos/page.tsx
  • frontend/src/app/(dashboard)/support/page.tsx
  • frontend/src/components/pos/PaymentModal.tsx
  • frontend/src/components/support/SupportTicketForm.tsx
  • frontend/src/lib/api.ts
  • frontend/src/lib/order-attempt.ts
  • frontend/src/lib/transport-failure.ts
  • main/lib/operation-failure.ts
  • main/routes/orders.ts
  • main/services/inventory.ts
  • package.json
  • tests/diagnostics-event.test.ts
  • tests/issue-788-order-attempt-storage.test.ts
  • tests/transport-failure-class.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@itsbkm

itsbkm commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@itsbkm
itsbkm enabled auto-merge (squash) November 13, 2026 22:00
@itsbkm
itsbkm merged commit 5d2ea59 into main Nov 13, 2026
23 checks passed
@itsbkm
itsbkm deleted the fix/support-findings-1551-b branch November 13, 2026 22:07
khaira777 pushed a commit to carvalab/FloCafe that referenced this pull request Nov 14, 2026
…ostHog operation_failed

Rebased onto main after FreeOpenSourcePOS#1556/FreeOpenSourcePOS#1557: adds shared ORDER_CREATE_DISPLAY_CODES, add-on capture points, PostHog operation_failed telemetry with report version/platform preservation, POS/Support Hub display_code handling, and pre-check refusal codes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant