-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
SlackAPIFileOperator is not propagating filetype API call #42889
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval. |
@hzlmn On debugging further with the data you shared above, could you tell me what method_version you are using to upload files using SlackOperator? The default one is "v2", while you can still pass the old version "v1". airflow/providers/src/airflow/providers/slack/operators/slack.py Lines 232 to 234 in e20146d
Here the execute method to invoke the Slack API chooses the upload based on the method version. airflow/providers/src/airflow/providers/slack/operators/slack.py Lines 257 to 271 in e20146d
The send_file method call of v1 function invokes API call where we send the filetype. The above issue fix that you have recommended applies here. Then there is another version v2 which is the updated version, where we upload file with different SDK method call. We pass a dict of file_uploads. ( in this dict we can pass file(or content) (here file represents the filepath, content represents the actual filecontent), filename, title, snippet_type, alt_txt) airflow/providers/src/airflow/providers/slack/hooks/slack.py Lines 289 to 322 in e20146d
In the above method we are passing the filetype into snippet_type. But snippet_type is an optional argument for syntax highlighting in case code content is uploaded. ( It can support types like python, HTML etc. Passing the filetype into snippet_type seems to be incorrect). In V2 version, there is no explicit way to pass the filetype, as I think with file upload directly as multipart binary, the metadata or MIME of the file content can be used to find the file type. @potiuk Can you tell me if I can raise a fix where we can get another param for snippet_type, rather than passing the filetype into it? |
Apache Airflow Provider(s)
slack
Versions of Apache Airflow Providers
2.9.2
Apache Airflow version
2.9.2
Operating System
MacOS 14.3.1
Deployment
Amazon (AWS) MWAA
Deployment details
No response
What happened
SlackAPIFileOperator
not propagating correctly filetype ending up sending csv file and json as plain text uploads.As you can see here
filetype
is passed to initial params but not used than in execution.https://github.com/apache/airflow/blob/main/providers/src/airflow/providers/slack/operators/slack.py#L263-L271
What you think should happen instead
Should correctly pass down
filetype
value.Can be fixed as following
How to reproduce
Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: