magento2
magento2 copied to clipboard
RestAPI add order comment without providing status sets status to NULL, preventing from showing in order grid
Preconditions (*)
- Magento 2.3.x, 2.4.x
- Existing order to add comments to
Steps to reproduce (*)
- Using the orders/{id}/comments endpoint, POST a new comment, but exclude "status" field (as is not required)
- Check the order in the sales_order, sales_order_grid database tables
- Check the order in the admin > Sales > order grid and Front-end -Customer login > My Orders page
Expected result (*)
- Order should maintain existing status
- Order should appear in adminhtml order grid and Front-end - My Orders page
Actual result (*)
- Order gets status set to NULL
- Order no longer appears in adminhtml order grid
- 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”.
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
addStatusHistoryCommentinstead? Although I guess this would remove the option to add a status/other history
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).
Details
If the issue has a valid description, the labelIssue: Format is validwill be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is validappears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Descriptionlabel to the issue by yourself. -
[ ] 3. Add
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced 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: Confirmedonce verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
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.


:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-1342 is successfully created for this GitHub issue.
: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.
Assign to me
Assign to me
This is still pending @bireney
Assign to me
@magento assign this to me
@magento I'm working on this
@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
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?
@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.
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