You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/01/29 07:34:00 UTC

[jira] [Commented] (AIRFLOW-3765) Can't create/update xcom values using the admin UI

    [ https://issues.apache.org/jira/browse/AIRFLOW-3765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16754686#comment-16754686 ] 

ASF GitHub Bot commented on AIRFLOW-3765:
-----------------------------------------

andyh1203 commented on pull request #4600: [AIRFLOW-3765] Fix for create/update xcom values using the admin UI
URL: https://github.com/apache/airflow/pull/4600
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Can't create/update xcom values using the admin UI
> --------------------------------------------------
>
>                 Key: AIRFLOW-3765
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3765
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: ui
>    Affects Versions: 1.10.0, 1.10.1, 1.10.2
>            Reporter: Michel Goldstein
>            Priority: Major
>         Attachments: Screen Shot 2019-01-24 at 8.46.08 AM.png
>
>
> When I try to create or update an xcom value using the admin UI I get an error saying:
> {noformat}
> Failed to create record. can't escape str to binary{noformat}
> Here is the full stack trace:
> {noformat}
> [2019-01-24 16:50:23,781] {{view.py:1087}} ERROR - Failed to create record.
> Traceback (most recent call last):
>   File "/usr/local/airflow/.local/lib/python3.6/site-packages/flask_admin/contrib/sqla/view.py", line 1083, in create_model
>     self.session.commit()
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 157, in do
>     return getattr(self.registry(), name)(*args, **kwargs)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 927, in commit
>     self.transaction.commit()
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 467, in commit
>     self._prepare_impl()
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 447, in _prepare_impl
>     self.session.flush()
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2209, in flush
>     self._flush(objects)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2329, in _flush
>     transaction.rollback(_capture_exception=True)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
>     compat.reraise(exc_type, exc_value, exc_tb)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
>     raise value
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 2293, in _flush
>     flush_context.execute()
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 389, in execute
>     rec.execute(self)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/unitofwork.py", line 548, in execute
>     uow
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
>     mapper, table, insert)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/persistence.py", line 835, in _emit_insert_statements
>     execute(statement, params)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 945, in execute
>     return meth(self, multiparams, params)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
>     return connection._execute_clauseelement(self, multiparams, params)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
>     compiled_sql, distilled_params
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
>     context)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1405, in _handle_dbapi_exception
>     util.reraise(*exc_info)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
>     raise value
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
>     context)
>   File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
>     cursor.execute(statement, parameters)
> TypeError: can't escape str to binary{noformat}
> This seems to be related to how flask-admin and SQLAlchemy integration works. All the other ways to set xcom values go through XCom.set() which will handle the pickling of the values before passing it onto the standard SQLAlchemy model. However, flask-admin does not call that method and will then try to add a string to a binary value within the model, thus the error above.
> I think the solution is to instead of provide a different "set" method, to declare the value type instead of a LargeBinary to provide a custom type that will then handle the serialization to binary (https://docs.sqlalchemy.org/en/rel_1_1/core/custom_types.html?highlight=typedecorator#sqlalchemy.types.TypeDecorator).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)