[
https://issues.apache.org/jira/browse/AIRFLOW-6385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17007625#comment-17007625
]
ASF GitHub Bot commented on AIRFLOW-6385:
-----------------------------------------
kaxil commented on pull request #7022: [AIRFLOW-6385] BugFix:
SlackAPIPostOperator fails when blocks not set
URL: https://github.com/apache/airflow/pull/7022
**Issue**:
After upgrade to 1.10.7 all slack notifications became faulty
SlackAPIPostOperator fails when blocks not set
```python
t_slack_ok = SlackAPIPostOperator(
task_id = 'notify_ok',
token = Variable.get('slack.token'),
channel = Variable.get('slack.channel'),
text = ':rocket: {{ dag.dag_id }} for {{ ds }} has succeeded',
dag = dag)
```
Causing an operator error:
```
[2019-12-28 21:55:14,668] {taskinstance.py:1088} ERROR - Slack API call
failed (invalid_blocks_format)
Traceback (most recent call last):
File
"/usr/local/lib/python3.6/dist-packages/airflow/models/taskinstance.py", line
955, in _run_raw_task
result = task_copy.execute(context=context)
File
"/usr/local/lib/python3.6/dist-packages/airflow/operators/slack_operator.py",
line 85, in execute
slack.call(self.method, self.api_params)
File "/usr/local/lib/python3.6/dist-packages/airflow/hooks/slack_hook.py",
line 62, in call
raise AirflowException(msg)
```
**Fix**:
It is because the default value is None and `json.dumps(None)` is null
which is not valid for Slack message
---
Link to JIRA issue: https://issues.apache.org/jira/browse/AIRFLOW-6385
- [x] Description above provides context of the change
- [x] Commit message starts with `[AIRFLOW-NNNN]`, where AIRFLOW-NNNN = JIRA
ID*
- [x] Unit tests coverage for changes (not needed for documentation changes)
- [x] Commits follow "[How to write a good git commit
message](http://chris.beams.io/posts/git-commit/)"
- [x] Relevant documentation is updated including usage instructions.
- [x] I will engage committers as explained in [Contribution Workflow
Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
(*) For document-only changes, no JIRA issue is needed. Commit message
starts `[AIRFLOW-XXXX]`.
---
In case of fundamental code change, Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party
License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in
[UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
Read the [Pull Request
Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)
for more information.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> SlackAPIPostOperator fails when blocks not set
> ----------------------------------------------
>
> Key: AIRFLOW-6385
> URL: https://issues.apache.org/jira/browse/AIRFLOW-6385
> Project: Apache Airflow
> Issue Type: Bug
> Components: operators
> Affects Versions: 1.10.7
> Reporter: Dmytro Kulyk
> Assignee: Kaxil Naik
> Priority: Critical
> Labels: slack
> Fix For: 1.10.8
>
>
> After upgrade to 1.10.7 all slack notifications became faulty
> SlackAPIPostOperator fails when blocks not set
> {code}
> t_slack_ok = SlackAPIPostOperator(
> task_id = 'notify_ok',
> token = Variable.get('slack.token'),
> channel = Variable.get('slack.channel'),
> text = ':rocket: {{ dag.dag_id }} for {{ ds }} has succeeded',
> dag = dag)
> {code}
> Causing an operator error:
> {code}
> [2019-12-28 21:55:14,668] {taskinstance.py:1088} ERROR - Slack API call
> failed (invalid_blocks_format)
> Traceback (most recent call last):
> File
> "/usr/local/lib/python3.6/dist-packages/airflow/models/taskinstance.py", line
> 955, in _run_raw_task
> result = task_copy.execute(context=context)
> File
> "/usr/local/lib/python3.6/dist-packages/airflow/operators/slack_operator.py",
> line 85, in execute
> slack.call(self.method, self.api_params)
> File "/usr/local/lib/python3.6/dist-packages/airflow/hooks/slack_hook.py",
> line 62, in call
> raise AirflowException(msg)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)