magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

RestAPI add order comment without providing status sets status to NULL, preventing from showing in order grid

Open edward-simpson opened this issue 4 years ago • 7 comments

Preconditions (*)

  1. Magento 2.3.x, 2.4.x
  2. Existing order to add comments to

Steps to reproduce (*)

  1. Using the orders/{id}/comments endpoint, POST a new comment, but exclude "status" field (as is not required)
  2. Check the order in the sales_order, sales_order_grid database tables
  3. Check the order in the admin > Sales > order grid and Front-end -Customer login > My Orders page

Expected result (*)

  1. Order should maintain existing status
  2. Order should appear in adminhtml order grid and Front-end - My Orders page

Actual result (*)

  1. Order gets status set to NULL
  2. Order no longer appears in adminhtml order grid
  3. Order no longer appears in front-end - My Orders page

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.
  • [x] 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”.

edward-simpson avatar Sep 28 '21 12:09 edward-simpson

Occurs because \Magento\Sales\Model\Order::addStatusHistory used in API call does not check if provided $history param has status set before using it:

$this->setStatus($history->getStatus());

I would create a PR to fix this but a decision needs to be made whether to either:

  • Make the rest API endpoint's "status" parameter required
  • Modify the addStatusHistory method to check for status before setting
  • Potentially use addStatusHistoryComment instead? Although I guess this would remove the option to add a status/other history

edward-simpson avatar Sep 28 '21 12:09 edward-simpson

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Sep 28 '21 13:09 m2-assistant[bot]

Verified the issue on Magento 2.4-develop branch and the issue is reproducible:

Steps performed: Created Order from front-end for a logged in customer using check/money Order. Order status is "Pending" Sent POST request to generate admin access token using: /rest/default/V1/integration/admin/token Sent POST request to /rest/V1/orders/15/comments to update comments for existing order using below sample payload: { "statusHistory": { "comment": "my api comment", "created_at": "2021-09-29 12:45:40", "entity_id": 15, "is_visible_on_front": 1 } } Issue: Order status is becoming NULL in "sales_order" table and "sales_order_grid" table Order is not getting displayed on Front-end - My Orders page Admin - View Order - Comment is also not added. image

image

engcom-November avatar Sep 29 '21 11:09 engcom-November

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-1342 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Sep 29 '21 11:09 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar Sep 29 '21 11:09 m2-assistant[bot]

Assign to me

bireney avatar Jan 18 '22 07:01 bireney

Assign to me

This is still pending @bireney

sivaganeshsg avatar Sep 22 '22 18:09 sivaganeshsg

Assign to me

koushikch7 avatar Jan 17 '23 15:01 koushikch7

@magento assign this to me

yogesh-valiya avatar Mar 16 '23 14:03 yogesh-valiya

@magento I'm working on this

yogesh-valiya avatar Mar 16 '23 14:03 yogesh-valiya

@yogesh-valiya @koushikch7 It will be taken care into one of the Internal JIRA ticket. Once Internal PR will get merged, we will notify.

Thank you!

glo05363 avatar Mar 20 '23 09:03 glo05363

@glo05363

I'm just repeating myself as this comment on :disappointed: - https://github.com/magento/magento2/issues/36800#issuecomment-1475712021

When I started working on this issue, the issue wasn't assigned to anyone. If the internal team was addressing the issue, may I inquire as to why it had not been assigned to someone specifically?

It's frequent, where an individual is working on a particular issue and raises a pull request, only to find out that there is already a pull request from the internal team in progress.

In light of this, I question the value of the effort put forth to resolve the issue. Could you clarify why the pull request is not linked to the issue if it is already in progress?

yogesh-valiya avatar Mar 20 '23 13:03 yogesh-valiya

@glo05363

I'm just repeating myself as this comment on 😞 - #36800 (comment)

When I started working on this issue, the issue wasn't assigned to anyone. If the internal team was addressing the issue, may I inquire as to why it had not been assigned to someone specifically?

It's frequent, where an individual is working on a particular issue and raises a pull request, only to find out that there is already a pull request from the internal team in progress.

In light of this, I question the value of the effort put forth to resolve the issue. Could you clarify why the pull request is not linked to the issue if it is already in progress?

I see your concern yogesh, Internal Team make sure to change status as per need, In this issue You will find above changes as PR:created by JIra-Sync_bot before you have tried to assign the same to yourself. Irrespective of that we will make sure to be more clear in terms of adding comment. As i can see the changes proposed in PR will not suffice , we will take care of the same in internal JIRA. We highly appreciate all the efforts in community, Internal PRs will not be linked here, once it is merged it will be available.

glo05363 avatar Mar 24 '23 07:03 glo05363

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-1342 by the internal team Related commits: https://github.com/magento/magento2/search?q=AC-1342&type=commits

Based on the Jira ticket, the target version is 2.4.7-beta1.

Thanks

engcom-Hotel avatar Apr 18 '23 14:04 engcom-Hotel