[
https://issues.apache.org/jira/browse/ARIA-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16000480#comment-16000480
]
Ran Ziv commented on ARIA-216:
------------------------------
This seems to be a bug in SQLAlchemy.
As can be seen in the full stack trace:
{code}
aria/storage/sql_mapi.py:117: in put
self._safe_commit()
aria/storage/sql_mapi.py:177: in _safe_commit
raise exceptions.StorageError('SQL Storage error: {0}'.format(str(e)))
../../.virtualenvs/aria/local/lib/python2.7/site-packages/sqlalchemy/exc.py:258:
in __str__
details.append("[parameters: %r]" % params_repr)
../../.virtualenvs/aria/local/lib/python2.7/site-packages/sqlalchemy/sql/util.py:363:
in __repr__
self._repr_multi(self.params[:self.batches - 2], typ)[0:-1],
../../.virtualenvs/aria/local/lib/python2.7/site-packages/sqlalchemy/sql/util.py:386:
in _repr_multi
for params in multi_params)
../../.virtualenvs/aria/local/lib/python2.7/site-packages/sqlalchemy/sql/util.py:386:
in <genexpr>
for params in multi_params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'str' object has no attribute 'items'") raised in
repr()] SafeRepr object at 0x7f1555704830>
params = '/path', typ = 2
def _repr_params(self, params, typ):
trunc = self.trunc
if typ is self._DICT:
return "{%s}" % (
", ".join(
"%r: %s" % (key, trunc(value))
> for key, value in params.items()
)
E AttributeError: 'str' object has no attribute 'items'
../../.virtualenvs/aria/local/lib/python2.7/site-packages/sqlalchemy/sql/util.py:401:
AttributeError
{code}
ARIA's code does attempt to raise a standard error message, but it fails when
attempting to get the message string of the internal SQL error.
It seems like this problem is very specific to the {{description}} field in the
service-template model, or rather any field which makes up the "first column"
in a table - using wrong types for other fields will work fine. This is because
of SQLAlchemy's {{sqlalchemy/sql/util.py}}'s {{_repr_params._repr_multi}}
method, which determines how to print according to the first column for some
reason.
> Creating a service-template model with incorrect description type results in
> a bad error message
> ------------------------------------------------------------------------------------------------
>
> Key: ARIA-216
> URL: https://issues.apache.org/jira/browse/ARIA-216
> Project: AriaTosca
> Issue Type: Bug
> Reporter: Ran Ziv
> Assignee: Ran Ziv
> Priority: Trivial
>
> Using the service-template model directly, when creating an instance whose
> description is of type `dict`, the following error message will appear:
> {code}
> "'str' object has no attribute 'items'"
> {code}
> Instead, one would expect a {{SQL Storage error: ...}} message.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)