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] web_editor: prevent TypeError while compute image src without checksum #159410

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from

Conversation

maan-odoo
Copy link
Contributor

Currently, an error is generated when [1] tries to access the first eight strings of the attachment.checksum but we got False.

Stack Trace:

TypeError: 'bool' object is not subscriptable
  File "odoo/http.py", line 2252, in __call__
    response = request._serve_db()
  File "odoo/http.py", line 1828, in _serve_db
    return self._transactioning(_serve_ir_http, readonly=ro)
  File "odoo/http.py", line 1848, 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 1826, in _serve_ir_http
    return self._serve_ir_http(rule, args)
  File "odoo/http.py", line 1833, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "odoo/http.py", line 2058, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "odoo/addons/base/models/ir_http.py", line 222, in _dispatch
    result = endpoint(**request.params)
  File "odoo/http.py", line 740, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "addons/web_editor/controllers/main.py", line 601, in modify_image
    return attachment.image_src
  File "odoo/fields.py", line 1193, in __get__
    self.compute_value(recs)
  File "odoo/fields.py", line 1375, in compute_value
    records._compute_field_value(self)
  File "odoo/models.py", line 4984, in _compute_field_value
    fields.determine(field.compute, self)
  File "odoo/fields.py", line 102, in determine
    return needle(*args)
  File "addons/web_editor/models/ir_attachment.py", line 53, in _compute_image_src
    unique = attachment.checksum[:8]

This commit will prevent the above issue by indexing the empty string instead of False.

[1]-

unique = attachment.checksum[:8]

sentry-4185609374

…ecksum

Currently, an error is generated when [1] tries to access the first eight
strings of the `attachment.checksum` but we got False.

Error : `TypeError: 'bool' object is not subscriptable`

This commit will prevent the above issue by indexing the empty
string instead of False.

[1]-https://github.com/odoo/odoo/blob/631e2bb1d3f9583200d6fe2f70006397425d5bd2/addons/web_editor/models/ir_attachment.py#L41

sentry-4185609374
@robodoo
Copy link
Contributor

robodoo commented Mar 27, 2024

@maan-odoo
Copy link
Contributor Author

Hello @odoo/sentry_reviewers
Please review this PR.

Thanks!

@C3POdoo C3POdoo added the RD research & development, internal work label Mar 27, 2024
@maan-odoo maan-odoo marked this pull request as ready for review March 27, 2024 07:41
@C3POdoo C3POdoo requested review from a team March 27, 2024 07:43
@maan-odoo maan-odoo changed the title [FIX] web_editor: prevent TypeErro while compute image src without checksum [FIX] web_editor: prevent TypeError while compute image src without checksum Mar 28, 2024
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

3 participants