Skip to content

Magento 2.4.7 – Undefined array key “policy_id” in /var/www/html/Aveeva/vendor/magento/module-csp/Model/Collector/ConfigCollector.php on line 111

My Code:

app/code/Aveeva/Csp/etc/csp_whitelist.xml

enter image description here

app/code/Aveeva/Csp/etc/config.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <csp>
            <mode>
                <storefront>
                    <report_only>0</report_only>
                </storefront>
                <admin>
                    <report_only>0</report_only>
                </admin>
            </mode>
            <policies>
                <!-- CORRECT: Apply to ALL storefront pages -->
                <storefront>
                    <script_src>
                        <inline>1</inline>
                        <eval>1</eval>
                    </script_src>
                </storefront>
            </policies>
        </csp>
    </default>
</config>

I am getting the following error

1 exception(s):
Exception #0 (Exception): Warning: Undefined array key "policy_id" in /var/www/html/aveeva/vendor/magento/module-csp/Model/Collector/ConfigCollector.php on line 111

Exception #0 (Exception): Warning: Undefined array key "policy_id" in /var/www/html/aveeva/vendor/magento/module-csp/Model/Collector/ConfigCollector.php on line 111
<pre>#1 MagentoCspModelCollectorConfigCollector->collect() called at [vendor/magento/module-csp/Helper/InlineUtil.php:283]