Ticket #1798 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

API search in non-q fields has exception for unicode characters

Reported by: dread Owned by:
Priority: awaiting triage Milestone:
Component: ckan Keywords:
Cc: icmurray Repository: ckan
Theme: none


You get an exception if you use the API to search packages and specify a non-ascii character in a field other than q.

For example:


This "N-dash" (Unicode character 2013) causes this exception:

Module ckan.controllers.api:460 in search
<<                      if ver in u'12':
                               # Otherwise, put all unrecognised ones into the q parameter
                               params = convert_legacy_parameters_to_solr(params)
                           query = query_for(model.Package)
                           results = query.run(params)
>>  params = convert_legacy_parameters_to_solr(params)
Module ckan.lib.search.query:38 in convert_legacy_parameters_to_solr
<<      for search_key in non_solr_params:
               value_obj = legacy_params[search_key]
               value = str(value_obj).replace('+', ' ')
               if search_key == 'all_fields':
                   if value:
>>  value = str(value_obj).replace('+', ' ')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 30: ordinal not in range(128)

This problem affects CKAN 1.5 and 1.5.1 only.

Change History

comment:1 Changed 2 years ago by dread

  • Cc icmurray added
  • Status changed from new to closed
  • Resolution set to fixed

Was fixed by Ian in https://github.com/okfn/ckan/commit/5a9054459e3833443bed3e118bbbb6c442e55b0b on branch feature-1453-flexible-tag-names.

This has gone into CKAN 1.6.

Note: See TracTickets for help on using tickets.