magento / magento/inventory

Call to a member function getIsVirtual() on null

Open
#2,271 2 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
PHP
Stars
357
Forks
262
PR merge metrics
No merged PRs in 30d

Description

Magento 2.3.1, happens locally using PHP 7.2, after returned from my 3dsecure test gateway to confirm order success.

```
Fatal error: Uncaught Error: Call to a member function getIsVirtual() on null in /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php:160 Stack trace: #0 /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php(148): Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor->hasValidItems(Object(Magento\Sales\Model\Order\Invoice)) #1 /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php(92): Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor->isValid(Object(Magento\Sales\Model\Order\Invoice)) #2 /home/ccarnell/Sites/vax-uk2/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor->execute(Object(Magento\Framework\Event\Observer)) #3 /home/ccarnell/Sites/vax-uk2/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\I in /home/ccarnell/Sites/vax-uk2/vendor/magento/module-inventory-shipping/Observer/VirtualSourceDeductionProcessor.php on line 160
```

Contributor guide

Open the contributing guide

Research direction

Start with Magento\InventoryShipping\Observer\VirtualSourceDeductionProcessor.php, especially execute(), isValid(), and hasValidItems() around lines 92–160. Reproduce the 3D Secure return flow described in the issue and trace why the invoice reaches getIsVirtual() with a null value; done means the scenario no longer raises this fatal error and has coverage for the failing path.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.