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 AnalysisProfile keyword validator fail with non-ascii value #2656

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

toropok
Copy link
Contributor

@toropok toropok commented Dec 5, 2024

Description of the issue/feature this PR addresses

If the keyword contains non-ASCII characters, it may cause exceptions to be raised by the validator method.

Current behavior before PR

If a keyword contains non-ASCII symbols, the api.search call produces unexpected behavior or errors.

2024-12-05T04:57:08 ERROR Zope.SiteErrorLog 1733374628.780.465720355575 https://mysenaite.best.lims.ever/clients/client-4/analysisprofile-108/@@edit
Traceback (innermost last):
  Module ZServer.ZPublisher.Publish, line 144, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZServer.ZPublisher.Publish, line 44, in call_object
  Module plone.z3cform.layout, line 63, in __call__
  Module plone.z3cform.layout, line 47, in update
  Module plone.dexterity.browser.edit, line 55, in update
  Module plone.z3cform.fieldsets.extensible, line 65, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 145, in update
  Module plone.app.z3cform.csrf, line 22, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module plone.dexterity.browser.edit, line 26, in handleApply
  Module z3c.form.group, line 98, in extractData
  Module z3c.form.form, line 148, in extractData
  Module z3c.form.field, line 324, in extract
  Module z3c.form.field, line 216, in validate
  Module z3c.form.validator, line 201, in validate
  Module z3c.form.validator, line 206, in validateObject
  Module zope.interface.interface, line 891, in validateInvariants
  Module senaite.core.content.analysisprofile, line 214, in validate_profile_key
  Module bika.lims.api, line 1013, in search
  Module Products.CMFPlone.CatalogTool, line 468, in searchResults
  Module Products.ZCatalog.ZCatalog, line 627, in searchResults
  Module Products.ZCatalog.Catalog, line 1094, in searchResults
  Module Products.ZCatalog.Catalog, line 637, in search
  Module Products.ZCatalog.Catalog, line 567, in _search_index
  Module Products.PluginIndexes.unindex, line 583, in query_index
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 4: ordinal not in range(128)

Desired behavior after PR is merged

Convert the keyword to an ASCII-compatible format before making the api.search call.

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@toropok toropok changed the title Fix prevent AnalysisProfile keyword validator fail with non-ascii value Fix AnalysisProfile keyword validator fail with non-ascii value Dec 5, 2024
Copy link
Contributor

@ramonski ramonski left a comment

Choose a reason for hiding this comment

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

Thanks Leo!

@ramonski ramonski merged commit 5d5edae into senaite:2.x Dec 6, 2024
1 check passed
@toropok toropok deleted the patch-6 branch December 6, 2024 14:50
@xispa xispa added the Bug 🐞 label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants