Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MUI controller lacks JSON response, instead returns status 200 with empty body #19859

Conversation

woutersamaey
Copy link
Contributor

@woutersamaey woutersamaey commented Dec 18, 2018

Description (*)

Example URL http://hostname/admin/mui/index/render/key/xxx/?namespace=notification_area&sorting%5Bfield%5D=created_at&sorting%5Bdirection%5D=asc&isAjax=true

Can return status 200 with an empty body, when it should return JSON. This later causes a JavaScript error because data.items does not exist.

This happens when the admin user does not have enough ACL rights to this controller.

Fixed Issues (if relevant)

  1. Valid JSON response
  2. Correct HTTP status code

Manual testing scenarios (*)

  1. Create an admin with very limited access rights (only orders for example)
  2. Go to the orders page.
  3. Look for error

data-storage.js:270 Uncaught TypeError: Cannot read property 'items' of null
at UiClass.onRequestComplete (data-storage.js:270)
at fire (jquery.js:3232)
at Object.fireWith [as resolveWith] (jquery.js:3362)
at done (jquery.js:9840)
at XMLHttpRequest.callback (jquery.js:10311)

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @woutersamaey. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

…ont-bvba/magento2 into mui-controller-lacks-json-return

# Conflicts:
#	app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
@woutersamaey
Copy link
Contributor Author

Forgot the return line at the end. Added it to the PR. Sorry.

@sidolov
Copy link
Contributor

sidolov commented Dec 18, 2018

@magento-engcom-team give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @sidolov. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @sidolov, here is your Magento instance.
Admin access: https://i-19859-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@sivaschenko sivaschenko self-assigned this Dec 19, 2018
@sivaschenko
Copy link
Member

@magento-engcom-team give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, here is your new Magento instance.
Admin access: https://pr-19859.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@sivaschenko
Copy link
Member

Hi @woutersamaey thanks for your contribution! Could you please fix the code style for static tests to pass.

With your fix an admin with limited permissions will see the screen like:
image

It would be nice to have an appropriate error (Not enough permissions), however, that's probably out of this pull request scope.

@woutersamaey
Copy link
Contributor Author

woutersamaey commented Dec 19, 2018

@sivaschenko You're right about this error message and indeed, it is out of scope. This error can come up in a number of situations and it's always vague. A more thorough refactoring is needed.

Also, the admin notifications should not try to load in the first place, as the user doesn't have the required rights, so dealing with the root cause is best.

These could be 2 new separate issues.

About the code style, this is just another one of those "i dont like else-statements" messages. We've ignored those in the past due to an overzealous Codacy.

Copy link
Member

@sivaschenko sivaschenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @woutersamaey thanks for your reply. We will not be able to merge the pull request to mainline without code style fixes. Please see my code suggestions. All you need to to do is to add these suggestions to batch and then commit them using github UI.

app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php Outdated Show resolved Hide resolved
app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php Outdated Show resolved Hide resolved
app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php Outdated Show resolved Hide resolved
sivaschenko and others added 3 commits December 20, 2018 14:50
Co-Authored-By: woutersamaey <wouter.samaey@storefront.be>
Co-Authored-By: woutersamaey <wouter.samaey@storefront.be>
Co-Authored-By: woutersamaey <wouter.samaey@storefront.be>
@woutersamaey
Copy link
Contributor Author

@sivaschenko OK, now I see what you mean. Thanks for preparing this for me. I have commited your suggestions.

Is everything OK now? Honestly I'm not 100% familiar with Github so please excuse me if I didn't understand correctly.

@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-3725 has been created to process this Pull Request

@p-bystritsky p-bystritsky force-pushed the mui-controller-lacks-json-return branch from 893ed7d to 25e04de Compare January 3, 2019 14:00
@p-bystritsky p-bystritsky force-pushed the mui-controller-lacks-json-return branch 2 times, most recently from 7718593 to 481bd15 Compare January 21, 2019 11:43
@p-bystritsky p-bystritsky force-pushed the mui-controller-lacks-json-return branch from 481bd15 to 8b97f75 Compare January 25, 2019 14:24
@okorshenko okorshenko removed this from the Release: 2.3.1 milestone Jan 28, 2019
@p-bystritsky p-bystritsky force-pushed the mui-controller-lacks-json-return branch from 8b97f75 to 94cb3f6 Compare February 6, 2019 11:14
@p-bystritsky p-bystritsky force-pushed the mui-controller-lacks-json-return branch from 94cb3f6 to 40d44c2 Compare February 7, 2019 12:15
@p-bystritsky p-bystritsky self-assigned this Mar 5, 2019
@nmalevanec nmalevanec self-assigned this Mar 7, 2019
@ghost
Copy link

ghost commented Mar 16, 2019

Hi @woutersamaey, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@magento-engcom-team magento-engcom-team merged commit 02f8c38 into magento:2.3-develop Mar 16, 2019
@magento-engcom-team magento-engcom-team added this to the Release: 2.3.2 milestone Mar 16, 2019
magento-engcom-team pushed a commit that referenced this pull request Mar 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants