Skip to content

Unable to remove parameter override for a webapi route #33843

Closed
@gowrizrh

Description

@gowrizrh

I stumbled upon the necessity to remove a parameter override which is defined in a webapi.xml

<route url="/V1/customers" method="POST">
    <data>
        <parameter name="customer.extension_attributes.company_attributes.company_id" force="true">%company_id%</parameter>
    </data>
</route>

My initial though was setting force="false" should remove the paramter being overwritten by the \Magento\Framework\Webapi\Rest\Request\ParamOverriderInterface, however that was not the case.

Upon closer look into the schema converter \Magento\Webapi\Model\Config\Converter that's responsible to read the xml files I found out the line that's responsible to parse the attribute is incorrect.

$force = $forceNode ? (bool)$forceNode->nodeValue : false;

Strings always evaluate to boolean true unless they have a value that's considered "empty" by PHP. PHP empty documentation

  1. ""
  2. "0"

Current work around is setting a falsy value so that works

<route url="/V1/customers" method="POST">
    <data>
        <parameter name="customer.extension_attributes.company_attributes.company_id" force="0">%company_id%</parameter>
    </data>
</route>

Preconditions (*)

  1. vanilla Magento 2.4.3

Steps to reproduce (*)

  1. Define an existing or new webapi route paramter override with force="false"

Expected result (*)

  1. The parameter override should have the value set to false

Using n98 to inspect (Magento\Webapi\Model\ConfigInterface::getServices()['routes']['V1/customers'])

[
    "POST" => [
        "secure" => false,
        "service" => [
            "class" => "Magento\Customer\Api\AccountManagementInterface",
            "method" => "createAccount",
        ],
        "resources" => [
            "anonymous" => true,
        ],
        "parameters" => [
            "customer.extension_attributes.company_attributes.company_id" => [
                "force" => false,
                "value" => "%company_id%",
            ],
        ],
    ],
]

Actual result (*)

  1. The paramter override still has the value true

Using n98 to inspect

[
    "POST" => [
        "secure" => false,
        "service" => [
            "class" => "Magento\Customer\Api\AccountManagementInterface",
            "method" => "createAccount",
        ],
        "resources" => [
            "anonymous" => true,
        ],
        "parameters" => [
            "customer.extension_attributes.company_attributes.company_id" => [
                "force" => true, # this is still true
                "value" => "%company_id%",
            ],
        ],
    ],
]

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: APIsComponent: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions