Skip to content

[codex] fix(inventory): handle string order status on receive#369

Merged
robotlearning123 merged 1 commit intomainfrom
codex/release-ready-order-status
Mar 28, 2026
Merged

[codex] fix(inventory): handle string order status on receive#369
robotlearning123 merged 1 commit intomainfrom
codex/release-ready-order-status

Conversation

@robotlearning123
Copy link
Copy Markdown
Member

Summary

Fix receive_items() so it handles order statuses loaded back from the database as plain strings instead of assuming an enum instance.

Root Cause

Order.status is stored as a string field. In a fresh session, SQLModel returns values like "received" as str, but receive_items() called order.status.value in the already-received/cancelled/deleted guard. That raised AttributeError instead of the intended ValidationError.

What Changed

  • Normalize the blocked-status label with getattr(order.status, "value", order.status) before building the validation message.
  • Add a regression test that commits the first receive, opens a new session, and verifies the second receive is rejected cleanly after reload.

Impact

  • Prevents a 500-class crash when a receive request hits an order already marked received in a prior transaction.
  • Preserves the intended user-facing validation behavior without changing any happy-path inventory logic.

Validation

  • uv run pytest -q tests/test_inventory_service_coverage.py -k 'receive'

@robotlearning123 robotlearning123 enabled auto-merge (squash) March 28, 2026 20:07
@robotlearning123 robotlearning123 force-pushed the codex/release-ready-order-status branch from 686e18a to d3c29bc Compare March 28, 2026 20:57
@github-actions github-actions bot added the ci-verified All required CI checks have passed label Mar 28, 2026
@robotlearning123 robotlearning123 merged commit 3f84c54 into main Mar 28, 2026
22 of 23 checks passed
@robotlearning123 robotlearning123 deleted the codex/release-ready-order-status branch March 28, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-verified All required CI checks have passed python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants