hzlmn opened a new issue, #42889:
URL: https://github.com/apache/airflow/issues/42889

   ### 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
   ```python
   class SlackAPIFileOperator(SlackAPIOperator):
       ...
       def execute(self, context: Context):
           self._method_resolver(
               channels=self.channels,
               # For historical reason SlackAPIFileOperator use filename as 
reference to file
               file=self.filename,
               filetype=self.filetype,   # here missing filetype
               content=self.content,
               initial_comment=self.initial_comment,
               title=self.title,
           )
   
   ```
   
   ### How to reproduce
   
   slack = SlackAPIFileOperator(
       task_id="slack_file_upload",
       dag=dag,
       slack_conn_id="slack",
       channel="#general",
       initial_comment="Hello World!",
       filename="hello_world.csv",
       filetype="csv",
       content="hello,world,csv,file",
   )
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to