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

[FIX] lunch: prevent indexerror when deleting topping #162207

Conversation

reka-odoo
Copy link
Contributor

When the user tries to delete the toppings,
a traceback appears.

Steps to reproduce the error:

  • Go to Lunch > Configuration > Vendors > Open any vendor
  • Now add extra 2 (topping 2) > Save
  • Delete that extra 2 (topping 2) > Save

Traceback:

IndexError: list index out of range
  File "odoo/http.py", line 2251, in __call__
    response = request._serve_db()
  File "odoo/http.py", line 1827, in _serve_db
    return self._transactioning(_serve_ir_http, readonly=ro)
  File "odoo/http.py", line 1847, in _transactioning
    return service_model.retrying(func, env=self.env)
  File "odoo/service/model.py", line 134, in retrying
    result = func()
  File "odoo/http.py", line 1825, in _serve_ir_http
    return self._serve_ir_http(rule, args)
  File "odoo/http.py", line 1832, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "odoo/http.py", line 2057, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "odoo/addons/base/models/ir_http.py", line 220, in _dispatch
    result = endpoint(**request.params)
  File "odoo/http.py", line 739, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "addons/web/controllers/dataset.py", line 38, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "addons/web/controllers/dataset.py", line 34, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "odoo/api.py", line 458, in call_kw
    result = getattr(recs, name)(*args, **kwargs)
  File "addons/web/models/models.py", line 71, in web_save
    self.write(vals)
  File "addons/lunch/models/lunch_supplier.py", line 193, in write
    topping_values = topping[2]

for topping in values.get('topping_ids_2', []):
topping_values = topping[2]
Here when the user deletes the extra 2 (topping 2),
"topping" will be [2,2] instead of [2,2,False].
So when it tries to access topping[2],
It will lead to the above traceback.

sentry-5203693767


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Apr 17, 2024

Pull request status dashboard.

@C3POdoo C3POdoo added the RD research & development, internal work label Apr 17, 2024
@reka-odoo reka-odoo force-pushed the 17.0-sentry-5203693767-indexerror-in-lunch-reka branch from bc30322 to e65a4bd Compare April 18, 2024 09:41
@reka-odoo
Copy link
Contributor Author

Hello @odoo/sentry_reviewers 👋
Please review this PR.
Thanks!

@adwid adwid requested a review from abla001 April 19, 2024 06:54
@reka-odoo reka-odoo force-pushed the 17.0-sentry-5203693767-indexerror-in-lunch-reka branch 2 times, most recently from d320ce3 to 5091f14 Compare April 22, 2024 12:26
Copy link
Contributor

@abla001 abla001 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@abla001 abla001 left a comment

Choose a reason for hiding this comment

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

make the comments above the lines

@reka-odoo reka-odoo force-pushed the 17.0-sentry-5203693767-indexerror-in-lunch-reka branch 2 times, most recently from b54c107 to 03da274 Compare April 22, 2024 12:41
@reka-odoo
Copy link
Contributor Author

make the comments above the lines

Done.

When the user tries to delete the toppings,
a traceback appears.

Steps to reproduce the error:
- Go to Lunch > Configuration > Vendors > Open any vendor
- Now add extra 2 (topping 2) > Save
- Delete that extra 2 (topping 2) > Save

Error: A traceback appears:
"IndexError: list index out of range"

https://github.com/odoo/odoo/blob/07f6d71e4dd3fac7b4cacc545819430aa48823cd/addons/lunch/models/lunch_supplier.py#L192-L193
Here when the user deletes the extra 2 (topping 2),
"topping" will be [2,2] instead of [2,2,False].
So when it tries to access topping[2],
It will lead to the above traceback.

sentry-5203693767
@reka-odoo reka-odoo force-pushed the 17.0-sentry-5203693767-indexerror-in-lunch-reka branch from 03da274 to 5d64eab Compare April 22, 2024 12:55
@maan-odoo maan-odoo marked this pull request as ready for review April 25, 2024 11:51
@C3POdoo C3POdoo requested a review from a team April 25, 2024 11:53
@reka-odoo
Copy link
Contributor Author

Hello @sofiagvaladze 👋
Can you review this PR?
Thanks!

@sofiagvaladze
Copy link
Contributor

robodoo r+

@robodoo robodoo closed this in 2a4adbe May 23, 2024
lohwswilson pushed a commit to lohwswilson/odoo that referenced this pull request Jun 5, 2024
When the user tries to delete the toppings,
a traceback appears.

Steps to reproduce the error:
- Go to Lunch > Configuration > Vendors > Open any vendor
- Now add extra 2 (topping 2) > Save
- Delete that extra 2 (topping 2) > Save

Error: A traceback appears:
"IndexError: list index out of range"

https://github.com/odoo/odoo/blob/07f6d71e4dd3fac7b4cacc545819430aa48823cd/addons/lunch/models/lunch_supplier.py#L192-L193
Here when the user deletes the extra 2 (topping 2),
"topping" will be [2,2] instead of [2,2,False].
So when it tries to access topping[2],
It will lead to the above traceback.

sentry-5203693767

closes odoo#162207

Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
@fw-bot fw-bot deleted the 17.0-sentry-5203693767-indexerror-in-lunch-reka branch June 6, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants