ckan icon indicating copy to clipboard operation
ckan copied to clipboard

Fix error handling in tabledesigner with new datastore column

Open EricSoroos opened this issue 1 month ago • 0 comments

Proposed fixes:

Table designer's templates assume that there are either no or len(fields) errors, but if there's an error when adding a new column, the error structure is a single element list

{'fields': ['"INVALID FIELDNAME " is not a valid field name']}

This eventually leads to an attribute error:

return { prefix + key: value for (key, value) in dict.items() }
AttributeError: 'str' object has no attribute 'items'

Deep in the jinja templating, because we're trying to get an attribute of a jinja.element.Undefined, and it fails.

design_fields.html tries to handle this case:

          errors=(errors.get('fields', [])[fields | length:] + [{}] * loop.length)[loop.index0]) }}

But this is returning an undefined item.

I'm not 100% on the solution here, because this isn't actually getting the error into the right place. I want to get some tests in, but more eyes make sense.

Features:

  • [ ] includes tests covering changes
  • [ ] includes updated documentation
  • [ ] includes user-visible changes
  • [ ] includes API changes
  • [ ] includes bugfix for possible backport

Please [X] all the boxes above that apply

EricSoroos avatar Nov 24 '25 11:11 EricSoroos