This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 46d45e09cb Explicitly handle exceptions raised by config parsing in 
AWS provider (#29587)
46d45e09cb is described below

commit 46d45e09cb5607ae583929f3eba1923a64631f48
Author: Jarek Potiuk <[email protected]>
AuthorDate: Fri Feb 17 13:50:14 2023 +0100

    Explicitly handle exceptions raised by config parsing in AWS provider 
(#29587)
    
    This PR handles all the exceptions that are raised by config parser
    when reading AWS configuration file and turns them into AirflowException
---
 airflow/providers/amazon/aws/utils/connection_wrapper.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/airflow/providers/amazon/aws/utils/connection_wrapper.py 
b/airflow/providers/amazon/aws/utils/connection_wrapper.py
index f5a30240d4..a0cdf23ae1 100644
--- a/airflow/providers/amazon/aws/utils/connection_wrapper.py
+++ b/airflow/providers/amazon/aws/utils/connection_wrapper.py
@@ -443,10 +443,13 @@ def _parse_s3_config(
     import configparser
 
     config = configparser.ConfigParser()
-    if config.read(config_file_name):  # pragma: no cover
-        sections = config.sections()
-    else:
-        raise AirflowException(f"Couldn't read {config_file_name}")
+    try:
+        if config.read(config_file_name):  # pragma: no cover
+            sections = config.sections()
+        else:
+            raise AirflowException(f"Couldn't read {config_file_name}")
+    except Exception as e:
+        raise AirflowException("Exception when parsing %s: %s", 
config_file_name, e.__class__.__name__)
     # Setting option names depending on file format
     if config_format is None:
         config_format = "boto"

Reply via email to