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 subversion and git services (JIRA)" <ji...@apache.org> on 2017/09/16 15:40:02 UTC

[jira] [Commented] (AIRFLOW-1177) variable json deserialize does not work at set defaults

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

ASF subversion and git services commented on AIRFLOW-1177:
----------------------------------------------------------

Commit 610f68b22a8277f9521d0b9989b4dd5ce7cbcfe0 in incubator-airflow's branch refs/heads/master from [~ashb]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-airflow.git;h=610f68b ]

[AIRFLOW-1177] Fix Variable.setdefault w/existing JSON

Previously due to a logic error if you attempt to
use
`Variable.setdefault()` with
`deserialize_json=True` and the value
already existed it would die with:

    ...
        my = Variable.setdefault('regions', ['uk'],
deserialize_json=True)
      File "/usr/local/lib/python3.5/site-
packages/airflow/models.py", line 3623, in
setdefault
        return json.loads(obj.val)
    AttributeError: 'str' object has no attribute
'val'

The problem was that the `Variable.get()` call was
returning the value,
not a variable object.

Closes #2540 from ashb/variable-setdefault-json


> variable json deserialize does not work at set defaults
> -------------------------------------------------------
>
>                 Key: AIRFLOW-1177
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1177
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: models
>    Affects Versions: Airflow 1.8
>            Reporter: barak schoster
>            Assignee: barak schoster
>
> at line:
> https://github.com/apache/incubator-airflow/blob/master/airflow/models.py#L3685
> obj has no attribute val, it is the val itself.
> it will throw error like:
> Variable.setdefault("some_key", deserialize_json=True,default=json.dumps(default_dag_variables))
>   File "/usr/local/lib/python2.7/site-packages/airflow/models.py", line 3586, in setdefault
>     return json.loads(obj.val)
> AttributeError: 'unicode' object has no attribute 'val'



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)