Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-6385] BugFix: SlackAPIPostOperator fails when blocks not set #7022

Merged
merged 1 commit into from
Jan 3, 2020

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Jan 3, 2020

Issue:
After upgrade to 1.10.7 all slack notifications became faulty
SlackAPIPostOperator fails when blocks not set

    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 layout: https://api.slack.com/messaging/composing/layouts


Link to JIRA issue: https://issues.apache.org/jira/browse/AIRFLOW-6385

  • Description above provides context of the change
  • Commit message starts with [AIRFLOW-NNNN], where AIRFLOW-NNNN = JIRA ID*
  • Unit tests coverage for changes (not needed for documentation changes)
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in 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) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@kaxil kaxil requested a review from potiuk January 3, 2020 16:53
@codecov-io
Copy link

codecov-io commented Jan 3, 2020

Codecov Report

Merging #7022 into master will decrease coverage by 0.23%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7022      +/-   ##
==========================================
- Coverage   84.73%   84.49%   -0.24%     
==========================================
  Files         679      679              
  Lines       38598    38598              
==========================================
- Hits        32706    32614      -92     
- Misses       5892     5984      +92
Impacted Files Coverage Δ
airflow/operators/slack_operator.py 100% <100%> (ø) ⬆️
airflow/kubernetes/volume_mount.py 44.44% <0%> (-55.56%) ⬇️
airflow/kubernetes/volume.py 52.94% <0%> (-47.06%) ⬇️
airflow/kubernetes/pod_launcher.py 45.25% <0%> (-46.72%) ⬇️
airflow/executors/sequential_executor.py 56% <0%> (-32%) ⬇️
airflow/kubernetes/refresh_config.py 50.98% <0%> (-23.53%) ⬇️
...rflow/contrib/operators/kubernetes_pod_operator.py 78.75% <0%> (-20%) ⬇️
airflow/utils/helpers.py 74.5% <0%> (-7.19%) ⬇️
airflow/utils/dag_processing.py 80.95% <0%> (-7.05%) ⬇️
airflow/jobs/scheduler_job.py 88.1% <0%> (-1.18%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5030f3...241a05d. Read the comment docs.

@kaxil kaxil merged commit 2adf17b into apache:master Jan 3, 2020
@kaxil kaxil deleted the fix-slack branch January 3, 2020 18:14
kaxil added a commit that referenced this pull request Jan 7, 2020
kaxil added a commit to astronomer/airflow that referenced this pull request Jan 8, 2020
galuszkak pushed a commit to FlyrInc/apache-airflow that referenced this pull request Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants